Transaction , rollback ..???
-
In a transaction block if any error for insert or update occures (e.g. caused by foreign key-primary key constraint violation) does the transaction automatically rolls back or do we need to manually roll it back ?
Best regards Hossein Yahoo ID :hosseinenick
-
In a transaction block if any error for insert or update occures (e.g. caused by foreign key-primary key constraint violation) does the transaction automatically rolls back or do we need to manually roll it back ?
Best regards Hossein Yahoo ID :hosseinenick
Syntax will go like this:
Begin Try Begin Transaction --Your Line of code Commit Transaction End Try Begin Catch RollBack Transaction End Catch --Your line of code
You will have to call commit or rollback for your transaction.....:-D -
Syntax will go like this:
Begin Try Begin Transaction --Your Line of code Commit Transaction End Try Begin Catch RollBack Transaction End Catch --Your line of code
You will have to call commit or rollback for your transaction.....:-D -
In a transaction block if any error for insert or update occures (e.g. caused by foreign key-primary key constraint violation) does the transaction automatically rolls back or do we need to manually roll it back ?
Best regards Hossein Yahoo ID :hosseinenick
It will rollBack "autopmatically" if you will say so. E.G.
BEGIN TRAN
your codeif @@error <> 0 goto err
-- more codeif @@error <> 0 goto err
At the end:commit tran return 1 err: rollback tran return 0
Sincerely, Elina Life is great!!! Enjoy every moment of it! :-O