Showing posts with label commiti. Show all posts
Showing posts with label commiti. Show all posts

Sunday, February 19, 2012

Commit and rollback

How are these placed exactly in the program. Do you run at 1 time or
different?
Example:
begin tran
delete
from enc
where epsid = '23232'
commit
I ran the above then ran the following to undo:
begin tran
rollback tran
That was it. I am not entirely sure how to put the transactions together to
enable the rollback if the data being changed it not correct.
Message posted via http://www.webservertalk.comTina,
Use the @.@.ERROR variable, like the following:
begin tran
delete from enc where epsid = '23232'
if @.@.ERROR = 0
commit tran
else
rollback tran
What this does is attempts to delete the record(s) from the enc table with
the given filter. If the query has a problem (fails, whatever), then the
@.@.ERROR variable will be set to some non-zero value. If the query completed
successfully, then the @.@.ERROR variable will be 0.
Hope that helps.
Richard
"tina miller via webservertalk.com" wrote:

> How are these placed exactly in the program. Do you run at 1 time or
> different?
> Example:
> begin tran
> delete
> from enc
> where epsid = '23232'
> commit
> I ran the above then ran the following to undo:
> begin tran
> rollback tran
> That was it. I am not entirely sure how to put the transactions together t
o
> enable the rollback if the data being changed it not correct.
> --
> Message posted via http://www.webservertalk.com
>|||I need something that I can do the rollback. This is in a training
environment and I need to be able to have it rollback.
Message posted via http://www.webservertalk.com