PeaceMaker
Programmer
I have written a stored procedure which consists of 3000 or more lines....
Now it is in transaction... i want to rollback if any of my sql statement fails during the processing..
I want to commit only when my Stored procedure is complete
I am using @@Error variable to find out whether the statement was a success or not...
My problem is that I have to check this @@Error variable after every DML statement...
Is there any way that i can write something like
On Error Goto ErrorHandler
And in that errorHandler i would like to rollback the transaction and terminnate the stored procedures
Please help as my 3000 lines of SP has about 200 lines of DML statements...
and the way i am handling erros
if @@Error <> 0
begin
Rollback transaction
Return
end
it means 200*5=1000 extra lines of code just for this purpose...
Please suggest...
Thanx
Ajay Handa (PeaceMaker)
Now it is in transaction... i want to rollback if any of my sql statement fails during the processing..
I want to commit only when my Stored procedure is complete
I am using @@Error variable to find out whether the statement was a success or not...
My problem is that I have to check this @@Error variable after every DML statement...
Is there any way that i can write something like
On Error Goto ErrorHandler
And in that errorHandler i would like to rollback the transaction and terminnate the stored procedures
Please help as my 3000 lines of SP has about 200 lines of DML statements...
and the way i am handling erros
if @@Error <> 0
begin
Rollback transaction
Return
end
it means 200*5=1000 extra lines of code just for this purpose...
Please suggest...
Thanx
Ajay Handa (PeaceMaker)