Using SQLSTATE and etc in HANDLER - Websphere

This is a discussion on Using SQLSTATE and etc in HANDLER - Websphere ; Hi all! I have a lack of understanding how to use SQLSTATE,SQLERRORTEXT,SQLNATIVEERROR in my case. I have written the following ESQL code: .... BEGIN DECLARE EXIT HANDLER FOR SQLSTATE LIKE '%' BEGIN DECLARE qwe REFERENCE TO SDSSegmentStatus; DECLARE qwe1 CHARACTER ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Using SQLSTATE and etc in HANDLER

  1. Using SQLSTATE and etc in HANDLER

    Hi all!
    I have a lack of understanding how to use SQLSTATE,SQLERRORTEXT,SQLNATIVEERROR in my case. I have written the following ESQL code:
    ....
    BEGIN
    DECLARE EXIT HANDLER FOR SQLSTATE LIKE '%'
    BEGIN
    DECLARE qwe REFERENCE TO SDSSegmentStatus;
    DECLARE qwe1 CHARACTER SQLSTATE;
    RECIEPTERROR : BEGIN
    ATOMIC
    SET SDSSegmentStatus.MSGSENT[<].IsSent = false;
    SET SDSSegmentStatus.MSGSENT[<].ErrorDetail = SQLERRORTEXT;
    SET SDSSegmentStatus.MSGSENT[<].ErrorCode = SQLCODE;
    SET SDSSegmentStatus.MSGSENT[<].NativeErrorCode = SQLNATIVEERROR;
    SET SDSSegmentStatus.MSGSENT[<].SQLState = SQLSTATE;
    END RECIEPTERROR;
    END;
    CREATE LASTCHILD OF SDSSegmentStatus TYPE Name NAME 'MSGSENT';
    SET SDSSegmentStatus.MSGSENT[<].LogicalMsgId = SDSLogicalMsgId;
    SET SDSSegmentStatus.MSGSENT[<]."Domain" = J."DOMAIN";
    SET SDSSegmentStatus.MSGSENT[<].IsSent = true;
    SET SDSSegmentStatus.MSGSENT[<].SeqNum = InputRoot.MQMD.MsgSeqNumber;
    SET SDSSegmentStatus.MSGSENT[<].ErrorCode = 0;
    -- test if there are errors for current domain in previous messages
    IF (FailedMsgs <> 0) THEN
    THROW USER EXCEPTION MESSAGE 3052 VALUES('One of previous messages failed. We don''t send new msg to this domain.') ;
    END IF;
    PROPAGATE TO TERMINAL 'out' DELETE NONE;
    END;
    ...
    The problem is that I can't get any information about error that happened. As I think Message Broker should populate SQLSTATE and etc. with this information. But all these registers are empty in my handler part in case of any error: throw exception by "THROW USER EXCEPTION" nor some error during PROPAGATE statement.
    Is there way to pass my string from "THROW USER EXCEPTION" to HANDLER part?
    I'll appreciate any help!
    Thank you in advance!

  2. Re: Using SQLSTATE and etc in HANDLER

    Have you found any solution.If yes,can you please share.I do have the same problem.

+ Reply to Thread