View previous topic :: View next topic
|
Author |
Message |
shoaib
New User
Joined: 20 Dec 2006 Posts: 5 Location: mumbai
|
|
|
|
I have multiple insert in my COBOL program and one of them is giving SQLCODE -530
The Program logic is as follows:
Enter program
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 ..
.
.
.
If success
Comitt
Else
Rollback
.
.
.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.
Thanks |
|
Back to top |
|
|
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi,
As of my knowledge, until unless you commits the data on the first table for the newly inserted row you will not insert a row on second table which has a Foreign key constraint from the first table.
Please correct me if I am wrong. |
|
Back to top |
|
|
Raghu navaikulam
Active User
Joined: 27 Sep 2008 Posts: 193 Location: chennai
|
|
|
|
Hi shoaib
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.
Regards
Raghu |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
I don't think the previous answers are correct. (well I'm pretty sure)
probably something else is wrong. |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
Can you please let us know what is happening in case you bring the commit in between the two inserts ?
Test a single case and post the result pls |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
with the same Primary Key P1 |
you are not, that is why you are receiving a -530 for the second insert.
Forget all the crap about commits.
It is your task,
all of your uncommited work is always available to your task.
the talk about a commit is simply rookie bullshit.
your problem is the data that you are using for the second insert does not jive with the parent table.
stop trying to find fault with db2. double check the values of your variables.
therein lies the problem. |
|
Back to top |
|
|
|