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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-04-12 : 08:34:37
|
| writes "Anybody know if the COALESCE(NULLIF ...)...) can raise error itself, and ifit safely to use this combination of checking error statusEvery time after i calling to some store procedure i use this:------------------------------------------DECLARE @intError intEXEC @intError = myProcedure @param1, @param2 .....SELECT @intError = COALESCE(NULLIF(@intError, 0), @@ERROR)IF(@intError =0 )............--------------------------------------------my question is, can the @@ERROR variable have an error that COALESCE orNULLIF function were raise?Thanks.P.S. if it's not good idea to use it after calling to stored procedures sowhat can u advice me" |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-04-12 : 08:49:17
|
so what's wrong with simpleSELECT @intError = @@ERRORif @intError <> 0 ... error handling@@error is 0 if there's no error.Go with the flow & have fun! Else fight the flow |
 |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2005-04-12 : 10:53:07
|
| I think that he's trying to make use of the return value from the sproc but then augment that with @@Error in case there was a problem at that level.An error can occur at anytime but your code looks pretty safe. I've never seen COALESCE or NULLIF raise an error. If an error did occur in either of these functions, I don't believe that @@Error would return it since the statement is executed atomically. The value of @Error would be the value it had when the SELECT statement began.HTH=================================================================In order to improve the mind, we ought less to learn than to contemplate.-Rene Descartes, philosopher and mathematician (1596-1650) |
 |
|
|
|
|
|