Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2007
    Posts
    50

    Unanswered: 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?

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  3. #3
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

  4. #4
    Join Date
    Sep 2007
    Posts
    50
    Thanks mate!
    that is brilliant.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •