Oracle 创建触发器语句失败,内部错误代码 ORA-00600

Posted

技术标签:

【中文标题】Oracle 创建触发器语句失败,内部错误代码 ORA-00600【英文标题】:Oracle Create trigger statement fails with internal error code ORA-00600 【发布时间】:2012-11-10 04:43:34 【问题描述】:

尝试执行从 Oracle 创建的转储文件。在此块之前,一切都可以正常创建和更改:

CREATE OR REPLACE TRIGGER "LABS"."CHANNEL_CHANNEL_ID_TRG" BEFORE INSERT ON channel
FOR EACH ROW
DECLARE 
v_newVal NUMBER(12) := 0;
v_incval NUMBER(12) := 0;
BEGIN
IF INSERTING AND :new.CHANNEL_ID IS NULL THEN
SELECT  channel_CHANNEL_ID_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
-- If this is the first time this table have been inserted into (sequence == 1)
IF v_newVal = 1 THEN 
  --get the max indentity value from the table
  SELECT NVL(max(CHANNEL_ID),0) INTO v_newVal FROM channel;
  v_newVal := v_newVal + 1;
  --set the sequence to that value
  LOOP
       EXIT WHEN v_incval>=v_newVal;
       SELECT channel_CHANNEL_ID_SEQ.nextval INTO v_incval FROM dual;
  END LOOP;
END IF;
--used to emulate LAST_INSERT_ID()
--mysql_utilities.identity := v_newVal; 
-- assign the value from the sequence to emulate the identity column
:new.CHANNEL_ID := v_newVal;
END IF;
END;

这会失败并切断连接,给出以下相当神秘的错误:

ORA-00603: ORACLE server session terminated by fatal error
ORA-00600: internal error code, arguments: [kqlidchg1], [], [], [], [], [], [], [], [], [], [], []
ORA-00604: error occurred at recursive SQL level 1
ORA-00001: unique constraint (SYS.I_PLSCOPE_SIG_IDENTIFIER$) violated
00603. 00000 -  "ORACLE server session terminated by fatal error"
*Cause:    An ORACLE server session is in an unrecoverable state.
*Action:   Login to ORACLE again so a new server session will be create

【问题讨论】:

db-eccentric.com/2011/04/ora-0600-type-of-day.html ORA-00600 表示一个 oracle 错误,在这种情况下似乎是 import 和 PL/Scope 之间的交互。在这种情况下,您的解决方法(关闭 PL/Scope)很好。如果需要使用PL/Scope,可以重新启用,重新编译触发器。 【参考方案1】:

找到了一个有效的解决方案。用以下 ALTER 语句包围代码块:

ALTER SESSION SET PLSCOPE_SETTINGS = 'IDENTIFIERS:NONE';

...这里是sql语句...

ALTER SESSION SET PLSCOPE_SETTINGS = 'IDENTIFIERS:ALL'; 

由于某种原因,Oracle 数据库转储不包含这些命令,但这解决了问题。

【讨论】:

以上是关于Oracle 创建触发器语句失败,内部错误代码 ORA-00600的主要内容,如果未能解决你的问题,请参考以下文章

在 Oracle 触发器代码中使用“exec”并失败

带有动态 sql 的 PL/SQL 触发器

oracle登录触发器造成无法登录

转://因触发器限制导致oracle用户登录失败

ORACLE 触发器里面执行建表语句不成功,求解!!!

oracle触发器使用总结