Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

why can't I get GET DIAGNOSTICS compiled?

$
0
0
Hi, I am totally lost when I using GET DIAGNOSTICS. I just copied the example from IBM official site:

http://pic.dhe.ibm.com/infocenter/dz...iagnostics.htm

and my code is

Code:

       

        DECLARE EXIT HANDLER FOR SQLEXCEPTION
        BEGIN

                GET CURRENT DIAGNOSTICS CONDITION 1 msg_text = MESSAGE_TEXT;
       
        END;

But I got the following error while compiling,

Code:

DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0104N  An unexpected token "GET CURRENT DIAGNOSTICS CONDITION" was found
following "EXCEPTION  BEGIN    ".  Expected tokens may include:
"<psm_statement>".  LINE NUMBER=43.  SQLSTATE=42601

I checked my db2 version and it should be version 9.7
db2licm -l
Product name: "DB2 Enterprise Server Edition"
License type: "CPU Option"
Expiry date: "Permanent"
Product identifier: "db2ese"
Version information: "9.7"
Enforcement policy: "Soft Stop"

Why I can't use GET DIAGNOSTICS this way ?

==============================================adde d below

I changed the code to

Code:

        DECLARE EXIT HANDLER FOR SQLEXCEPTION
        BEGIN

                GET DIAGNOSTICS EXCEPTION 1 msg_text = MESSAGE_TEXT;
       
        END;

it works, but I want to use the line_number
Code:

        DECLARE EXIT HANDLER FOR SQLEXCEPTION
        BEGIN

                GET DIAGNOSTICS exception 1 RETVAL = DB2_LINE_NUMBER;

        END;

and I got following error:

Code:

DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0104N  An unexpected token "DB2_LINE_NUMBER" was found following "exception
1 RETVAL =".  Expected tokens may include:  "<psm_diag_condition_item>".  LINE
NUMBER=42.  SQLSTATE=42601

I am wondering how can I get line number where the sql error occurred?

Viewing all articles
Browse latest Browse all 13329

Trending Articles