dcsimg
@@error, @return code from sybase stored proc
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   vamshi_krisshna
Posted On:   Monday, August 27, 2001 08:22 PM

Question :

when does execute on callable statement throws exception? Does it throw exception when sybase stored proc retruns non zero @@error code? OR we need to check for the code somehow?


Thank you

Re: @@error, @return code from sybase stored proc

Posted By:   Bozidar_Dangubic  
Posted On:   Tuesday, August 28, 2001 05:20 AM

you can raise exceptions yourself from stored procedures and provide error codes by RDBMS also raises exceptions when they occur. when you execute a statement you should be catching SQLException somewhere in the code. that is the exception thrown by RDBMS to indicate that some went awry. calling getErrorCode() will return a vendor specific integer value which then you can cross-reference in the manual to find out the exact cause of the exception. you can also dictate what the error codes are by "catching" exceptions in the stored procedures yourself and setting error codes to custom-defined values. here is a snippet of code you may use. you have to test it on sybase, though.


ON EXCEPTION set sql_err, isam_err, error_info
------------------------------
--Return the error information and exit.
------------------------------
RAISE EXCEPTION sql_err, isam_err, error_info;
END EXCEPTION;


you can programatically alter the value of sql_err value and other values if you want to define custom-defined error codes for your application. consult sybase SPL manuals for exact syntax and specification on this.
About | Sitemap | Contact