Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rollback a delete query

Status
Not open for further replies.

Fatih235

MIS
May 30, 2002
19
0
0
US
Hi all;

I have a problem with rollback a delete query.Here is what i wrote;

BEGIN TRANSACTION trans1
delete from auto where auto_id=5

and this delete the record whose auto_id=5

The problem is when i wrote ;

ROLLBACK TRANSACTION trans1 i get get an error message like

"there os no transaction or savepoint as named trans1"

All these stuff works when i tried with insert query.It is obviously that i am doing something wrong.What shall i do?
 
Dear ;

It is also working for me, I have checked it here and it roll backs the delete record.

I think the problem is that you did not select the first line when you run that delete query. Select and run these two line in one batch.

BEGIN TRANSACTION trans1
delete from auto where auto_id=5

Then run it.

ROLLBACK TRANSACTION trans1

Regards,
Essa Mughal



 
Okay i did ,what u said.
It says "one row effected",but then when i write

select * from auto where auto_id=5

it gives nothing(zero results).So i didnt understand how it rolled back?what is wrong?
 
Dear ;

first disconnect all connections then follow these steps.

Try to use this syntax ;

first run this :

BEGIN TRANSACTION
delete from auto where auto_id=5

Then run this :
select * from auto where auto_id=5

It gives you nothing.

Then run it.

ROLLBACK TRANSACTION

It gives you successfully message.

Then run this :
select * from auto where auto_id=5

It gives you your record.

It is only for checking purpose.

Regards,
Essa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top