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
But I got the following error while compiling,
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
it works, but I want to use the line_number
and I got following error:
I am wondering how can I get line number where the sql error occurred?
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;
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
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;
Code:
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
GET DIAGNOSTICS exception 1 RETVAL = DB2_LINE_NUMBER;
END;
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