If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > A possible COMMIT issue

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-27-12, 13:21
zevang zevang is offline
Registered User
 
Join Date: Dec 2009
Posts: 55
A possible COMMIT issue

I'm trying to figure out what happens when I collect, say, 100 rows to be inserted into a table, and, before the COMMIT, an error occurs. The error in this case is caused by the client application which tries to insert a row with a duplicate primary key (no need to detail why the app does this, but let's assume it's not possible to change this).

The situation is that the APP asked the DB to record, say, 50 rows and then it sends one row with a duplicate primary key. The DB refuses to receive this row and the APP collects an error message. Then, the APP sends another 50 rows, without any problems. Then the COMMIT comes to the scene.

Is it possible that the second group of 50 rows are lost because of the duplicate key error?
Reply With Quote
  #2 (permalink)  
Old 01-27-12, 13:35
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Quote:
(no need to detail why the app does this, but let's assume it's not possible to change this)
I don't want to varnish over erroneous apps.
But, you are free to go your way. I should not critisize you, or see quietly.
Reply With Quote
  #3 (permalink)  
Old 01-27-12, 14:17
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
If a SQL statement fails, DB2 will undo all changes made by this SQL statement (and only this statement). Previous or succeeding SQL statement in the same transaction will succeed (or fail) independent of this one statement. Everything else can be derived from the ACID properties for transactions.

In short: you have n statements inserting some rows, which succeeds. Then you have one statement, which fails - this doesn't cause the transaction to be rolled back (at least not in DB2). Then you have another set of n statements inserting some more rows. Then you commit. You'll have all the modifications of the successful statements in your system.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 01-27-12, 17:22
zevang zevang is offline
Registered User
 
Join Date: Dec 2009
Posts: 55
Thanks a lot, stolze.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On