dbTalk Databases Forums  

ASE 11.9; SProcs; testing @@error; When to test it??

comp.databases.sybase comp.databases.sybase


Discuss ASE 11.9; SProcs; testing @@error; When to test it?? in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
bonzo
 
Posts: n/a

Default ASE 11.9; SProcs; testing @@error; When to test it?? - 12-04-2003 , 02:04 PM






Sybase documentation for Strored Procs indicates that global variable
@@error should be checked as follows...
"Every Transact-SQL statement, including print statements and if tests,
resets @@error, so the status check must immediately follow the batch whose
success is in question."

So what we've done is test after EVERY line in our SProcs...
.....
select @todaydate = getdate()
if @@error <> 0 goto error_out
select @num_rows = COUNT(*) from can_2_job where c2j_c_key = @cankey
if @@error <> 0 goto error_out
open canjobs_spf1ce
if @@error <> 0 goto closeit_error_out
fetch canjobs_spf1ce into @thiscan, @thisjob
if @@error <> 0 goto closeit_error_out
.....
close canjobs_spf1ce
if @@error <> 0 goto error_out
deallocate cursor canjobs_spf1ce
if @@error <> 0 goto error_out

Needless to say, our SProcs are chock-filled with these lines, which I'm
guessing are not really useful.

Can anyone provide any general guidance as to when @@error should be checked
(and when it is not necessary)? The code as we've written it can't be what
the documentation intended we do.

Many Thanks





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.