Getting Error Message inside a Stored Proc Exception Handler

Database
Enthusiast

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.

1 REPLY
Teradata Employee

Re: Getting Error Message inside a Stored Proc Exception Handler

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