Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2012
    Posts
    8

    Unanswered: DB2 ET CURRENT DIAGNOSTICS CONDITION 1 Error

    hey folks,

    Version: DB2 v9.7.0.3

    OS: AIX

    3rd party: Toad 4.0.1.921(free version)

    I m getting below error while compiling below script--
    DB2 Database Error: ERROR [42601] [IBM][DB2/AIX64] SQL0104N An unexpected token "GET CURRENT DIAGNOSTICS CONDITION 1 msg_text = MESSA" was found following " ". Expected tokens may include: "<psm_statement>". LINE NUMBER=18. SQLSTATE=42601

    CREATE PROCEDURE divide2 ( IN numerator INTEGER,

    IN denominator INTEGER,

    OUT divide_result INTEGER,

    OUT divide_error VARCHAR(70))

    LANGUAGE SQL

    BEGIN

    DECLARE msg_text CHAR(70) DEFAULT '';

    DECLARE divide_error CHAR(70) DEFAULT '';



    DECLARE CONTINUE HANDLER FOR SQLEXCEPTION

    BEGIN

    insert into ngcore_tmp.a(roll)values(99); -- insert row into a log table



    -- get diagnostic information for the INSERT statement

    GET CURRENT DIAGNOSTICS CONDITION 1 msg_text = MESSAGE_TEXT;



    -- get information about condition that activated the handler

    GET STACKED DIAGNOSTICS CONDITION 1 divide_error = MESSAGE_TEXT;

    END;



    SET divide_result = numerator/denominator;

    END;

    Actually I want to get below info in case of any exception/error which I will keep in the log table-



    1> Error Code

    2> Error Message(generic msg)

    3> Status



    Please help me out.

    Thanks in advance

  2. #2
    Join Date
    Apr 2012
    Posts
    1,034
    Provided Answers: 18
    'get current diagnostics' is db2 for z/os syntax, but your post indicates AIX.

    For LUW the syntax is here:
    GET DIAGNOSTICS - IBM DB2 9.7 for Linux, UNIX, and Windows

Tags for this Thread

Posting Permissions

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