I have multiple insert in my COBOL program and one of them is giving SQLCODE -530
The Program logic is as follows:
Read a record
My first insert is on a table which has a Primary key ... This insert goes fine.. say Primay Key inserted was P1
My second insert is on table which has a Foriegn key contraint from the first table and now when I try inserting on this table with the same Primary Key P1 it throws an SQLCODE of -530 ..
.Read Next Record
I suspect that the second INSERT statement cannot see the Primary key that was inserted in the First table since the commit is down below.
And I dont want to put the commit between them coz there are many insert lined up and the requirement is if one fails all should rollback.
I tried with changing the ISOLATION LEVEL to UR in the BIND but i'm still getting the same error.
I would appreciate your suggestions in fixing this issue.
As you hint about the error, it is a foreign key violation. DB2 is using buffer to process its data. DB2 will not immediately write all the data into the table from the buffer unless the program issues a COMMIT or the buffer get filled. So the possible correction is to issue a commit on the UOW by redefining your business logic.