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 > Sybase > usage of BEGIN ATOMIC

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-30-08, 05:19
MPetris MPetris is offline
Registered User
 
Join Date: Dec 2007
Posts: 4
usage of BEGIN ATOMIC

Hi all,

I'm using Sybase SQL Anywhere 10.0.1.3722

I have a question regarding the use of BEGIN ATOMIC:

As I understood the database has to run in CHAINED MODE to use an atomic block, because I can not use commit/rollback inside it.
So whats the use of the atomic block if I have to execute commit/rollback after exiting that block and with the database being in chained mode everything since the last commit/rollback is one big atomic operation anyway.
It seems to me that marking the BEGIN-END-block as 'atomic' has no effect.

Thanks in advance for any explanations.

Regards

Marco
Reply With Quote
  #2 (permalink)  
Old 09-30-08, 10:52
jmgrhm jmgrhm is offline
Registered User
 
Join Date: Sep 2008
Posts: 2
Using BEGIN ATOMIC will ensure the statements between BEGIN and END will execute completely or not at all. If there are many SQL statements between BEGIN ATOMIC and END and an error occurs in any of those statements, everything done to the database since the BEGIN ATOMIC will be undone.
Reply With Quote
  #3 (permalink)  
Old 09-30-08, 11:23
MPetris MPetris is offline
Registered User
 
Join Date: Dec 2007
Posts: 4
hmm, I thought the chained mode will handle that already for me. If I'm in chained mode I have execute a rollback (in case of error) and everything since the last commit will be undone. Or in case of success I execute a commit and everything will be written to the database. That's already atomic...
Reply With Quote
  #4 (permalink)  
Old 09-30-08, 11:32
jmgrhm jmgrhm is offline
Registered User
 
Join Date: Sep 2008
Posts: 2
BEGIN ATOMIC is different in two ways. First, the operations are undone automatically (no ROLLBACK statement). Second, you are not undoing everything from the beginning of the transaction, but just to the beginning of the compound statement. This is most useful when you are doing EXCEPTION handling.
Reply With Quote
  #5 (permalink)  
Old 09-30-08, 11:41
MPetris MPetris is offline
Registered User
 
Join Date: Dec 2007
Posts: 4
Thanks a lot!
Reply With Quote
Reply

Thread Tools
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