×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Transaction rollback question
2

Transaction rollback question

Transaction rollback question

(OP)
I have a scenario where I will be updating (incrementing) a field in an MS SQLServer table multiple times within a transaction.  If I call SetAbort, will all of the updates be rolled back?  

Basically, the scenario goes like this:

I have a collection of order items that need to have an  item# assigned to them before inserting the record in the order table.  To do this, I have a lookup table that contains the batch# assigned to these orders and the most recently used item# in the batch + 1 .  When the SP is called to insert the new order, I grab the item#, increment it in the lookup table (so it's ready for the next order item), and then insert the order record.  

I realize all of the inserted orders should be rolled back, but what I'm wondering is if I call SetAbort, will all of the increments that were done to item# in the lookup table be rolled back so that the item# value is the first one I started with.  It seems to me they should, but I want to make sure.

Let me know if this doesn't make sense and I'll try and elaborate.

Thanks,
Brice

RE: Transaction rollback question

2
Yes! All of the updates will be rolled back .Because updating the lookup table is in same transaction as inserting into order tabble.

Regards!

zallen@cmmail.com
Long live of freedom!

RE: Transaction rollback question

This will cause roll back all the transaction as it is
in a single transaction.

RE: Transaction rollback question

(OP)
Thanks.

RE: Transaction rollback question

Hi,
  The Funda of using this is either the transaction should commit or rollback, here you are having update & insert in the same transaction so SetAbort will rollback all the changes upto that mark
Regards
BG

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close