If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Capturing the error message text in a 'continue handler'

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-16-07, 16:39
jeremym jeremym is offline
Registered User
 
Join Date: Oct 2007
Posts: 7
Capturing the error message text in a 'continue handler'

Hi all,

I'm wanting to capture a error message text such as:
SQL0530N The insert or update value of the FOREIGN KEY
"TST01.TEST_RETURNS.F_EXAM_TYPE" is not equal to any value of the
parent key of the parent table. SQLSTATE=23503
in a sql stored procedure continue handler so it can be logged as to why it couldn't be processed and the next record processed.

I've got code that records the sqlcode or sqlstate for logging. Whilst the sqlcode/sqlstate indicate that there has been a FK violation, it doesn't indicate on what FK. Important on tables with lots of FKs!


thanks
Reply With Quote
  #2 (permalink)  
Old 10-16-07, 16:54
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
What DB2 version and OS?

This is for V8 and higher for LUW:

DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
GET DIAGNOSTICS EXCEPTION 1 MESSAGE_TEXT_OUT = MESSAGE_TEXT;

END;


HTH

Andy
Reply With Quote
  #3 (permalink)  
Old 10-16-07, 17:15
jeremym jeremym is offline
Registered User
 
Join Date: Oct 2007
Posts: 7
Hi Andy,

thanks for your quick response! Just what I was looking for. It is simple when you know how - I just didn't know what I should have been looking for.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On