EXIT HANDLER NOT WORKING

Database

EXIT HANDLER NOT WORKING

    REPLACE  PROCEDURE Sysdba.PDBA_PROD_SpaceMover

       (

         IN  InTargetDB    VARCHAR(30)

       , IN  InSpace       BIGINT

       , OUT OutMessage    VARCHAR(1000)

       )

       BEGIN

         DECLARE vTargetDB      VARCHAR(30);

         DECLARE vTempDB        VARCHAR(30);

         DECLARE vUserName      VARCHAR(30);

         DECLARE vClientId      VARCHAR(30);  

         DECLARE vDate          DATE;

         DECLARE vTime          TIME(0);

         DECLARE vSession       INTEGER;

         DECLARE vSpace         BIGINT;

         DECLARE vBaseSpace     BIGINT;

         DECLARE vStatementNo   BYTEINT;

         DECLARE vStatement     VARCHAR(500);

         DECLARE vTempDBChk SMALLINT;

         DECLARE vTargetDBChk SMALLINT;

         --*****************************************

         --* Error handling

         --*****************************************

         DECLARE EXIT HANDLER FOR SQLEXCEPTION

         BEGIN

           DECLARE vSQLError   INTEGER;

           DECLARE vSQLState   INTEGER;

        DECLARE vErrorMsg   VARCHAR(1000);

           --* Save the error codes

           SET vSQLError = SQLCODE;

           SET vSQLState = SQLSTATE;

           --* Write the audit log

                    INSERT INTO Dxwi_System.PROD_SpaceMover_Log

         VALUES ( :vDate, :vTime, :vClientId, :vUserName, :vSession

                , :InTargetDB, :vSpace, :vStatementNo, :vStatement, :vSQLError, :vSQLState);

           --* Output the error message

        SELECT ErrorText  

        FROM DBC.ErrorMsgs  T1,

        Dxwi_System.PROD_SpaceMover_Log T2

           WHERE T1.ERRORCODE = T2.SQLCODE

           AND T2.SessionID = SESSION

           AND ERRORCODE <> 0 --Errorcode would be 0 for successful transactions, hence ignoring such values to get the error message

           GROUP BY 1

           INTO vErrorMsg;

           SET OutMessage = 'Failure!! , SQLCODE = ' || vSQLError || ' Error Message = ' || vErrorMsg;

         END;      

         --*****************************************

         --* Main processing

         --*****************************************

         --* Get the information from the user session

            SELECT CURRENT_DATE, CURRENT_TIME, USER, SESSION

            INTO vDate, vTime, vUserName, vSession;

         --* Get the ClinetId from the current user session

           SELECT TPXId

           FROM

        (SELECT

         SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)) AS One

        ,  SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) AS Two

        , SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))) AS Three

        , SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))))) AS Four\

        , SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))))))), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))))))))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))))))) AS Five

        , CASE

            WHEN SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) LIKE '%GCDCOM4%' THEN SUBSTR ( (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))),1,POSITION (' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))))))

             ELSE SUBSTR ( (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))))))), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))))))))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))))))))),1,POSITION (' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))))))), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))))))))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) ))))))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )), (POSITION( ' ' IN (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))+1) , CHAR (TRIM(SUBSTR ( (TRIM (SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))), (POSITION( ' ' IN (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource)))))+1) , CHAR (TRIM(SUBSTR(  LogonSource,(POSITION(' ' IN LogonSource)+1), CHAR(LogonSource))))) )))))))))))))

          END AS TPXId

        FROM DBC.SessionInfo

        WHERE SessionNo = SESSION

        )T INTO vClientId;

          --* Set the procedure variables

         SET vTargetDB  = UPPER(TRIM(InTargetDB));

         SET vTempDB    = 'DDBA' || '_' || TRIM(vSession) || '_' || SUBSTR('support_reserve',6,3) || '_' || SUBSTR(vTargetDB,6,3); --DDBA% will identify all the databases that are created on the fly

         SET vBaseSpace = 1000000000;

         SET vSpace     = InSpace * vBaseSpace;

        --*Check if Target DB Exists

         SELECT COUNT(1) FROM DBC.Databases WHERE Databasename  = ''||vTargetDB||'' INTO vTargetDBChk;

       --**************************************************************************

         --* Check for Target Databases existence

         IF vTargetDBChk = 0 THEN

        BEGIN

     CALL DBC.SYSEXECSQL ('Select *;');  -- Dummy statement to set sql state to non zero value

        SET OutMessage = 'Invalid Selection!! , TARGET = ' || InTargetDB || 'does not exist!!';

        END;  

         END IF;

         --*transferring the space

        IF  vTargetDBChk <> 0  THEN

          BEGIN

          SELECT COUNT(1) FROM DBC.Databases WHERE Databasename = TRIM(vTempDB) INTO vTempDBChk ;

          IF vTempDBChk <> 0 THEN

          SET vStatementNo = 0;

         SET vStatement = 'DROP DATABASE '|| vTempDB ||';';

         CALL DBC.SYSEXECSQL (:vStatement);

         END IF;   

         --* Create the TEMP database from vSourceDB

         SET vStatementNo = 1;

         SET vStatement = 'CREATE DATABASE '|| vTempDB || ' FROM SUPPORT_RESERVE' || ' AS PERM = ' || TRIM(vSpace) ||';';

         CALL DBC.SYSEXECSQL (:vStatement);

         --* Move the TEMP database to the vTargetDB

         SET vStatementNo  = 2;

         SET vStatement = 'GIVE '|| vTempDB || ' TO ' || vTargetDB || ';';

         CALL DBC.SYSEXECSQL (:vStatement);

         --INSERT INTO Dxwi_System.TDBA_Dev_SpaceMover_Log

         --VALUES ( :vDate, :vTime, :vClientId, :vUserName, :vSession, :InSourceDB

         --       , :InTargetDB, :vSpace, :vStatementNo, :vStatement, 0, 0 );

         --* Drop the TEMP database to make vTargetDB larger

         SET vStatementNo = 3;

         SET vStatement = 'DROP DATABASE ' || vTempDB || ';';

         CALL DBC.SYSEXECSQL (:vStatement);

         --* Logs the Success to the log table

         INSERT INTO Dxwi_System.PROD_SpaceMover_Log

         VALUES ( :vDate, :vTime, :vClientId, :vUserName, :vSession

                , :InTargetDB, :vSpace, :vStatementNo, NULL, 0, 0 ); -- not capturing vStatement on Success to avoid un-necessary space usage

         --* Output the success message

         SET OutMessage = 'Success!! ' || ' TARGET = ' || InTargetDB || ', SPACE = ' || TRIM(InSpace) || 'GB';

        END;

        END IF;

       END;

Can you please help. THe exit handler is not working