I am importing data into a staging table and perform several validation checks against the data in the stored procedure prior to updating the production tables. If any logical errors are encountered, the update statements do not process. However, if the update statements do start to process, I want them all to work or none. Therefore, if one abends, I want to roll back all updates. Can someome please provide me the correct syntax for catching ensuring this happens. The pseudo code for what I want to do is below. If an update statement blows up and the stored procedure abends, do all of the update statements get rolled back if you have a transaction defined?
Thanks,
check errors
If no errors
begin transaction
peform update 1
perform update 2
commit transaction
end if
if error - roll back all updates.
Thanks,
check errors
If no errors
begin transaction
peform update 1
perform update 2
commit transaction
end if
if error - roll back all updates.