All Forums Database
RonaldBrayan 7 posts Joined 11/15
29 Feb 2016
Getting Error Message inside a Stored Proc Exception Handler

Hi All,

 

I'm a core-DBA, not much idea in  stored Proc's.

 

I have written a a SP with Exception CONTINUE HANDLER. My requirement is to get the Error Message from the errors if any. I have written the code as below, please let me know if this is the correct way of capturing the Error Message, or is there a better way of writing ?

 

DECLARE CONTINUE HANDLER FOR SQLSTATE '42000'

E1: BEGIN

::::some code logic here...

GET DIAGNOSTICS EXCEPTION 1 ErrMsg_value = MESSAGE_TEXT ;

SET ErrCode_value = SQLCODE ;

END E1;

 

 

May be this is simple for you guy's..Thanks in advance.

 

Adeel Chaudhry 773 posts Joined 04/08
06 Mar 2016

Looks good. Are you sure you want to continue after getting an exception?

-- If you are stuck at something .... consider it an opportunity to think anew.

You must sign in to leave a comment.