earwig75
asked on
A question about SQL Transactions
I have a couple queries wrapped in an SQL transaction like below. If one or more of the sql statements fails or doesn't complete properly, I'd like to rollback everything automatically. Is this possible? Thank you.
BEGIN TRANSACTION;
INSERT INTO.....
UPDATE tblBlah...
INSERT INTO....
COMMIT TRANSACTION;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>would I need to add anything to the catch, other than the rollback?
No, other than to figure out a graceful way to report back to the calling code that the overall transaction was rolled back so it doesn't assume that the transaction was successfully committed.
No, other than to figure out a graceful way to report back to the calling code that the overall transaction was rolled back so it doesn't assume that the transaction was successfully committed.
ASKER
@Bill Prew, thank you! Both of these seem great.