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.
Author |
Topic |
ratcho
Starting Member
18 Posts |
Posted - 2003-12-09 : 11:26:39
|
Hello to all!I need something like ON ERROR Resume Next while using nested stored procedures.I have 2 stored procedures: spA calls spB. CREATE PROCEDURE spAAS....(some code)exec spB...(some code)GOI want to be sure that spA will continue even if spB produces errors.How can I do this!Please help me! |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-12-09 : 11:34:55
|
>> I want to be sure that spA will continue even if spB produces errors.You can never guarantee that this will be possible as a lot of errors abort the batch.Error handling is implemented by checking @@error after each statement and acting accordingly.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-12-09 : 12:03:09
|
You would need to ensure spA has proper error handling and returns a code indicating success or failure. Then, from that code, you would determine if spA succeded. As Nigel says, if you don't trap errors in spA, the entire thing may terminate.- Jeff |
|
|
ratcho
Starting Member
18 Posts |
Posted - 2003-12-09 : 12:43:09
|
Thanks a lot guys!As I understood I have to write something like this:---1st solution---------CREATE PROCEDURE spAAS....(some code)exec spBIF @@Error<>0BEGIN (don't do anything)END...(some code)GO-- OR ----2nd solution---------CREATE PROCEDURE spAASDECLARE @return_Err....(some code)exec @return_Err=spB...(some code)GO--AND---CREATE PROCEDURE spBAS.....(I have only one statement here)IF (@@Error<>0) RETURN 1ELSE RETURN 0ENDGOI will try this. Thanks a lot! |
|
|
|
|
|