IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Issue with DB2 Commit


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
veeramanimurugesan

New User


Joined: 03 Nov 2009
Posts: 19
Location: chennai

PostPosted: Wed Mar 02, 2011 10:18 pm
Reply with quote

Hi,

I am testing a simple cobol+db2 program which will read a file and insert the record in table if that key is not present already.

Now, when testing i took sample 14 records. My commit frequency is 3. After processing 8 records (8 inserts) i am force abending the program. The statistics show that 2 commits were issued as expected which would mean that there should be 6 committed rows.

But i see only 3 rows in the table. I changed commit freq as 2 and abend the program at 8 rows. In this case also, though 8 rows need to be present in table, only 2 are.

So, upon abend DB2 is rolling back all rows till the FIRST issued commit. I issued displays and i could see that all 6/8 rows are indeed getting successfully inserted in DB2 but upon rollback all of them except till the first commit get deleted.

Please advise.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Mar 02, 2011 10:43 pm
Reply with quote

I'm pretty sure your problem is in your coding and not in db2.

Maybe you should put a display at the commit. My guess is you forgot to reset the counter to 0 and only commit when count = 2 and not every 2.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Mar 02, 2011 11:30 pm
Reply with quote

Hello,

Run a test COMMITing after every insert (6 or 8 - it won't matter) and force the abend. Are all of the rows in the table? They most likely will be.

Then determine why the rows were either not really inserted or why the commit frequency was not followed.

Does the code check the sqlcode after every sql statement?
Back to top
View user's profile Send private message
veeramanimurugesan

New User


Joined: 03 Nov 2009
Posts: 19
Location: chennai

PostPosted: Wed Mar 02, 2011 11:40 pm
Reply with quote

Thanks for the quick turnaround GuyC.

I had put displays inside my commit para and also displayed the SQLCODE after commit. I could see successful commits and sqlcode of 0.

But still, the abend causes to rollback everything till first commit. I saw in the BMC abend logs as well that 2 commits have been issued.
Back to top
View user's profile Send private message
veeramanimurugesan

New User


Joined: 03 Nov 2009
Posts: 19
Location: chennai

PostPosted: Wed Mar 02, 2011 11:47 pm
Reply with quote

Hello Dick,

Thanks for your response.

Yes the code checks and handles sqlcode after every sql statement.

Commit frequency is also honored which i could see from displays. Commit gives sqlcode 0.

I had put a SELECT as soon as the INSERT is done. There, the program is indeed fetching the row which just got inserted. When commit freq is 3, i see all 8 SELECTS after INSERTS are successful. But when it abends, except for first 3 rows everything gets rolled back.

On a normal basis, the program just runs fine and all rows are correctly updated and committed. The rollback till first commit problem arises when an abend occurs.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Mar 03, 2011 12:30 am
Reply with quote

Hello,

Well, it is almost certain that the problem is in the code.

If DB2 was to not honor successful commits occasionally, we would have many topics on this as well as clarification from IBM.

Did you run the test where a COMMIT is issued after every INSERT? If not do so now and let us know what happens. Suggest you comment out the frequency check for this test and place the COMMIT immediately after the sqlcode check following the INSERT.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Issue after ISPF copy to Linklist Lib... TSO/ISPF 1
No new posts Facing ABM3 issue! CICS 3
No new posts Panvalet - 9 Character name - Issue c... CA Products 6
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top