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 > Get diagnostics exception - error line

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-08-07, 11:59
iskander iskander is offline
Registered User
 
Join Date: Sep 2007
Posts: 50
Get diagnostics exception - error line

How can I in a SQL stored procedure use Get diagnostics exception to get the line where the error occurred?
Reply With Quote
  #2 (permalink)  
Old 11-08-07, 14:04
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Line? Are you talking about the line number of the stored procedure or the row information?

The get diagnostics provides information from the SQLCA (RTFM if you don't don't know what SQLCA is).
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 11-09-07, 12:04
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
SQLCA doesn't contain line number. It wouldn't make much sense if the SP changes once in a while and the line numbers would change. Instead, you could use some probe mechanism:
Code:
DECLARE probe INT DEFAULT 0;

...
SET probe = 1;
...do something that may throw an exception...

SET probe = 28;
...do something that may throw an exception...
Then your condition handler can check the value in the "probe" variable and return that in a message text or something. That would be much more stable.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 11-09-07, 12:07
iskander iskander is offline
Registered User
 
Join Date: Sep 2007
Posts: 50
Thanks mate!
that is brilliant.
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