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 > atomic and not atomic - clarity

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-05-04, 11:41
db2guru1 db2guru1 is offline
Registered User
 
Join Date: Aug 2003
Posts: 106
atomic and not atomic - clarity

Version:
UDB Version 8.1 SQL PL

Example:
BEGIN NOT ATOMIC
...
SQL STATEMENT 1
SIGNAL SQLSTATE '70000'
SQL STATEMENT 2
END

The spec says that in the above example the SQL STATEMENT 1 will NEITHER be rolled back or commited? What DOES this mean??? If it is neither rolled back or commited then is it in limbo???

In my testing the SQL STATEMENT 1 was an insert into a table A and after the run of the above procedure the insert is NOT executed!
__________________

You are the creator of your own destiny!
Reply With Quote
  #2 (permalink)  
Old 07-05-04, 12:05
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
ATOMIC Compound Statement
The ATOMIC compound statement, as the name suggests, can be thought of as a singular whole—if any unhandled error conditions arise within it, all statements which have been executed up to that point are considered to have failed as well and are therefore rolled back. ATOMIC compound statements cannot be nested inside other ATOMIC compound statements.

In addition, you cannot use SAVEPOINTs or issue explicit COMMITs or ROLLBACKs from within an ATOMIC compound statement.

NOTE

COMMIT, ROLLBACK, SAVEPOINTS and nested ATOMIC compound statements are not allowed within an ATOMIC compound statement.


NOT ATOMIC Compound Statement
If an unhandled error (that is, no condition handler has been declared for the SQLSTATE raised) occurs within the compound statement, any work which is completed before the error will not be rolled back, but will not be committed either. The group of statements can only be rolled back if the unit of work is explicitly rolled back using ROLLBACK or ROLLBACK TO SAVEPOINT . You can also COMMIT successful statements if it makes sense to do so.
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 07-05-04, 12:22
db2guru1 db2guru1 is offline
Registered User
 
Join Date: Aug 2003
Posts: 106
Sathyaram_s:

Your definition is in sync with the book!

My question was specific to NOT ATOMIC - If the successfull SQL statements (before the error happened) are not committed or rolled back then what really happens to these statements? Or is it just how it has been implemented
__________________

You are the creator of your own destiny!
Reply With Quote
  #4 (permalink)  
Old 07-05-04, 13:46
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
Quote:
Originally Posted by db2guru1
Sathyaram_s:

Your definition is in sync with the book!

My question was specific to NOT ATOMIC - If the successfull SQL statements (before the error happened) are not committed or rolled back then what really happens to these statements? Or is it just how it has been implemented
They are not rolled back OR commited, so it's up to you to either do a ROLLBACK or COMMIT to determine what happens to them.
__________________
--
Jonathan Petruk
DB2 Database Consultant
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