Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 error checking

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-07-23 : 07:27:27
eswar writes "I have a main stored Procedure which is calling three stored procedures consecutively inside the Main.

If any error occured the entire transaction should roll back.
So I am checking the if @@error after the exectuion of each stored procedure and redirecting to erorhandle by using goto label;

But I am getting the following error
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION

How to resolve this.

Thanks in advance

Regards
Prabhakar"

X002548
Not Just a Number

15586 Posts

Posted - 2003-07-23 : 09:19:37
Do this..

DECLARE @rc int

EXEC @rc = EXEC sproc

inside the sproc return a value other than 0 to determine if the sproc was successful or not...



Brett

8-)
Go to Top of Page

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2003-07-23 : 09:39:12
You could also check if the currently open transactions have been rolled back by one of the inner stored procs or as a result of an error, before you issue the ROLLBACK TRAN Statement. The @@TRANCOUNT global variable comes in handy here:

IF (@@TRANCOUNT > 0 AND @@ERROR <> 0)
BEGIN
ROLLBACK TRAN
RETURN -1
END

Owais

Go to Top of Page
   

- Advertisement -