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 Administration (2000)
 raise error

Author  Topic 

sona
Yak Posting Veteran

68 Posts

Posted - 2004-04-07 : 01:02:59
i am calling a Procedure B From Procedure A.

In Proc B i have to return a userdefined Error using Raiserror.

In Proc A i have to capture that error using @@error to do some error handling.

when i use
"RAISERROR(' CREDIT LIMIT UPDATION FAILED IN CCSA DB',16,1)"
in Procedure B, the procedure gets abruptly terminated and comes out of Procedure A without going into the exception handling part.

What severity level should i use ???

Please help

REgards,
Deepa

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-04-07 : 01:36:55
Don't use RAISERROR. Use RETURN @someNumber to exit the query.

Call the procedure from Procedure A like I am doing in this set of examples. You can do what you need to do and raise the error at the end of ProcA in an error return section. Make sense?

CREATE PROCEDURE test_return

AS

RETURN 5

GO

CREATE PROCEDURE test_return_wrap

AS

DECLARE @return INT

EXEC @return = test_return

PRINT @return
--Do what you need to do.
--Then raise the error
GO

EXEC test_return_wrap


MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

sona
Yak Posting Veteran

68 Posts

Posted - 2004-04-07 : 01:48:33
Thanks.

My situation is this.

Procedure B will update a Table.
That table has a update Trigger.
Inside the trigger on my failure case i want to return error and how can i handle it in my procedure b and then in procedure A.

The raise error in trigger is aborting
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-04-07 : 08:57:11
Set your raise level from 16 to 10 and try that.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -