遇到 Oracle 错误 ORA-6502
Posted
技术标签:
【中文标题】遇到 Oracle 错误 ORA-6502【英文标题】:Oracle Error ORA-6502 encountered 【发布时间】:2014-12-23 13:16:14 【问题描述】:我有一个应该执行两个包的触发器...
代码...
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;
/
【问题讨论】:
由于它在 proc 中失败,我建议包括 proc 代码。为了减少大量的代码(这将导致大多数潜在的帮助者快速转向另一个问题),您可以摆脱大部分EXCEPTION
块
并且不要忘记添加所有错误描述,而不仅仅是错误代码。
在众多和以前的测试运行中,执行包的代码 100% 工作。我看不出为什么在执行包时会遇到 Ora 6502 错误?甲骨文中是否有可能改变的设置?需要紧急帮助。
【参考方案1】:
被调用程序中的变量导致触发器出错。已纠正并且应用程序有效。谢谢。
【讨论】:
以上是关于遇到 Oracle 错误 ORA-6502的主要内容,如果未能解决你的问题,请参考以下文章
jdbc连接oracle11g出现ora-12505错误怎么解决?
linux下安装好oracle12c,然后sqlplus启动出现如下问题ORA-01034、ORA-27101,求高手,linux如何启动orac
[ORACE] Oracle trace 之二10046事件