遇到Oracle Error ORA-6502

时间:2014-12-23 13:16:14

标签: oracle plsql

我有一个应该执行两个包的触发器......

守则......

DROP TRIGGER SLCFILEARRIVE_TRG;

CREATE OR REPLACE TRIGGER SLCFILEARRIVE_TRG
-- PL/SQL BLOCK
 BEFORE INSERT OR UPDATE
 ON SET_LOADER_CNTL
 REFERENCING OLD AS OLD NEW AS NEW
 FOR EACH ROW
DECLARE
   PRAGMA AUTONOMOUS_TRANSACTION;
--
    v_MAIN_LODR_APP             VARCHAR2(30) := Null;
    v_RECEIVE_FILENAME          VARCHAR2(20) := Null;      
    v_FILETYPE_HSCT_VLI         VARCHAR2(01) := 'N';
    v_SERVICE                   VARCHAR2(04) := Null;
    v_VisaService               VARCHAR2(04) := Null;
    v_SUBSERVICE                VARCHAR2(05) := Null;
    v_Centre                VARCHAR2(03) := Null;
    v_Currency                  VARCHAR2(03) := Null;
--
    v_servcntl_prddate          VARCHAR2(08) := Null;
    v_servcntl_serv             VARCHAR2(08) := 'SET';
--
    v_prg                   VARCHAR2(10)  := RPAD(REPLACE('SLCFLEARRV','x',' '),10,' ');
    v_vrs                   VARCHAR2(02)  := '04';
    v_spo                   VARCHAR2(03)  := 'SET';  
    v_spomsg                VARCHAR2(200) := Null;
--
    v_loader_parameter          VARCHAR2(50)  := Null;
    v_loader_parameter1         VARCHAR2(50)  := Null;
    v_loader_parameter2         VARCHAR2(50)  := Null;    
--
    v_trace                 VARCHAR2(06)  := Null;  
--  
BEGIN
--      
  EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_DATE_FORMAT = ''YYYYMMDD''';
--
    v_trace := 'SLC001';
    v_spo := v_servcntl_serv;
--
    :NEW.SERVICE        := RTRIM(:NEW.SERVICE);
    :NEW.SUB_SERVICE    := RTRIM(NVL(:NEW.SUB_SERVICE,'NONE'));

    v_SERVICE           := RTRIM(:NEW.SERVICE);
    v_SUBSERVICE        := RTRIM(:NEW.SUB_SERVICE);
    v_trace := 'SLC002';
    v_MAIN_LODR_APP     := RTRIM(:NEW.MAIN_LODR_APP);
    v_trace := 'SLC003';     
    v_RECEIVE_FILENAME  := RTRIM(:NEW.RECEIVE_FILENAME);
    v_trace := 'SLC004';    
    v_FILETYPE_HSCT_VLI := :NEW.FILETYPE_HSCT_VLI;
    v_Centre        := :NEW.CENTRE;
    v_Currency          := :NEW.CURRENCY;
--    
    v_trace := 'SLC005';
    Select TO_CHAR(prd_date,'YYYYMMDD')
      Into v_servcntl_prddate
    From Service_Control
    Where RTRIM(service) = v_servcntl_serv;
--
    v_trace := 'SLC006';
    IF :NEW.FILE_ARRIVED = 'Y' AND NVL(:OLD.FILE_ARRIVED,'N') <> 'Y' then
    v_trace := 'SLC06d';

    -- Trigger Fails here...

    SETFLELDRC.Main_Process(v_SERVICE, 
                    v_SUBSERVICE, 
                    v_Centre, 
                    v_Currency, 
                    v_RECEIVE_FILENAME, 
                    v_FILETYPE_HSCT_VLI
                       );

    v_trace := 'SLC06e';        
    :NEW.FILETYPE_HSCT_VLI := v_FILETYPE_HSCT_VLI;
    v_trace := 'SLC06f';        
    v_spomsg := 'Loader Completed for ('||v_SERVICE||' '||v_SUBSERVICE
            ||' '||v_Centre||' '||v_Currency
            ||' '||v_RECEIVE_FILENAME||') - Status = ('||v_FILETYPE_HSCT_VLI||')';
    Spo_Write(v_prg, v_spo, v_vrs, v_spomsg);      
    END IF;
--
    v_trace := 'SLC06g';
--    
EXCEPTION
WHEN ACCESS_INTO_NULL         THEN
    spo_write(v_prg, v_spo, v_vrs, 'Your program attempts to assign values to the attributes of an uninitialized (atomically null) object.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN COLLECTION_IS_NULL         THEN
    spo_write(v_prg, v_spo, v_vrs,'Your program attempts to apply collection methods other than EXISTS to an uninitialized (atomically null) nested table or varray, or the program attempts to assign values to the elements of an uninitialized nested table or varray.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN CURSOR_ALREADY_OPEN         THEN
    spo_write(v_prg, v_spo, v_vrs,'Your program attempts to open an already open cursor. A cursor must be closed before it can be reopened. A cursor FOR loop automatically opens the cursor to which it refers. So, your program cannot open that cursor inside the loop.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN DUP_VAL_ON_INDEX         THEN
    spo_write(v_prg, v_spo, v_vrs,'Your program attempts to store duplicate values in a database column that is constrained by a unique index.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN INVALID_CURSOR         THEN
    spo_write(v_prg, v_spo, v_vrs,'Your program attempts an illegal cursor operation such as closing an unopened cursor.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN INVALID_NUMBER         THEN
    spo_write(v_prg, v_spo, v_vrs,'In a SQL statement, the conversion of a character string into a number fails because the string does not represent a valid number.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN LOGIN_DENIED             THEN
    spo_write(v_prg, v_spo, v_vrs,'Your program attempts to log on to Oracle with an invalid username and/or password.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN NO_DATA_FOUND             THEN
    spo_write(v_prg, v_spo, v_vrs,'A SELECT INTO statement returns no rows, or your program references a deleted element in a nested table or an uninitialized element in an index-by table. SQL aggregate functions such as AVG and SUM always return a value or a null.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN NOT_LOGGED_ON             THEN
    spo_write(v_prg, v_spo, v_vrs,'Your program issues a database call without being connected to Oracle.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN PROGRAM_ERROR             THEN
    spo_write(v_prg, v_spo, v_vrs,'PL/SQL has an internal problem.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN ROWTYPE_MISMATCH         THEN
    spo_write(v_prg, v_spo, v_vrs,'The host cursor variable and PL/SQL cursor variable involved in an assignment have incompatible return types.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN SELF_IS_NULL             THEN
    spo_write(v_prg, v_spo, v_vrs,'Your program attempts to call a MEMBER method on a null instance.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN STORAGE_ERROR             THEN
    spo_write(v_prg, v_spo, v_vrs,'PL/SQL runs out of memory or memory has been corrupted.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN SUBSCRIPT_BEYOND_COUNT     THEN
    spo_write(v_prg, v_spo, v_vrs,'Your program references a nested table or varray element using an index number larger than the number of elements in the collection.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN SUBSCRIPT_OUTSIDE_LIMIT     THEN
    spo_write(v_prg, v_spo, v_vrs,'Your program references a nested table or varray element using an index number (-1 for example) that is outside the legal range.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN SYS_INVALID_ROWID         THEN
    spo_write(v_prg, v_spo, v_vrs,'The conversion of a character string into a universal rowid fails because the character string does not represent a valid rowid.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN TIMEOUT_ON_RESOURCE         THEN
    spo_write(v_prg, v_spo, v_vrs,'A time-out occurs while Oracle is waiting for a resource.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN TOO_MANY_ROWS             THEN
    spo_write(v_prg, v_spo, v_vrs,'A SELECT INTO statement returns more than one row.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');
WHEN VALUE_ERROR             THEN
    v_spomsg := '('||v_trace||') - Failed VALUE ERROR';
    Spo_Write(v_prg, v_spo, v_vrs, v_spomsg);        
    spo_write(v_prg, v_spo, v_vrs,'An arithmetic, conversion, truncation, or size-constraint error occurs.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'0000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE trg - COMPLETED UNSUCCESSFULLY ');
WHEN ZERO_DIVIDE             THEN
    spo_write(v_prg, v_spo, v_vrs,'Your program attempts to divide a number by zero.');
    spo_write(v_prg, v_spo, v_vrs,'*** ERROR - ' || TO_CHAR(SQLCODE,'00000') || ' - ' || SQLERRM);
    spo_write(v_prg, v_spo, v_vrs,'SLCFILEARRIVE TRG - COMPLETED UNSUCCESSFULLY ');

WHEN OTHERS THEN
     RAISE_APPLICATION_ERROR(-20310,SQLERRM||'SLCFILEARRIVE Trigger ERROR');
END;
/

1 个答案:

答案 0 :(得分:0)

被调用程序中的变量导致触发器发生错误。整改和应用程序的工作。感谢。