ORA-04088:执行触发期间出错

时间:2017-03-05 17:21:21

标签: sql oracle oracle-apex

错误:

ORA-00036: maximum number of recursive SQL levels (50) exceeded
ORA-00036: maximum number of recursive SQL levels (50) exceeded
ORA-06512: at "SYS.STANDARD", line 180
ORA-06512: at "ETRACKER.R_TRACKER_TRI", line 7
ORA-04088: error during execution of trigger 'ETRACKER.R_TRACKER_TRI'
ORA-06512: at "ETRACKER.R_TRACKER_TRI", line 24
ORA-04088: error during execution of trigger 'ETRACKER.R_TRACKER_TRI'
ORA-06512: at "ETRACKER.R_TRACKER_TRI", line 24 ORA-04088: error during execution of trigger 'ETRACKER.R_TRACK

触发码:

create or replace TRIGGER  R_TRACKER_TRI
   before insert on R_TRACKER
   for each row
   declare
   v_number varchar2(15);
   begin
      if inserting then 
         :NEW.PROJECT_ID := 1;--PROJECT_ID(1);
         :NEW.PRO_CREATED := LOCALTIMESTAMP;
         :NEW.PRO_CREATED_BY := nvl(v('APP_USER'),USER);

         IF :NEW.RECRUITMENT_TYPE= 'New' THEN
            SELECT ('NEW/'||TO_CHAR(SYSDATE,'YY') || '/' || (NVL(MAX(SUBSTRB(PROJECT_ID,8)),10000)+1)) into v_number 
            FROM R_TRACKER
            WHERE SUBSTRB(PROJECT_ID,1,3) = 'NEW';

            :NEW.PROJECT_ID := v_number;
         elsif :NEW.RECRUITMENT_TYPE= 'Replacement' THEN
            SELECT ('REP/'||TO_CHAR(SYSDATE,'YY') || '/' || (NVL(MAX(SUBSTRB(PROJECT_ID,8)),10000)+1)) into v_number 
            FROM R_TRACKER
            WHERE SUBSTRB(PROJECT_ID,1,3) = 'REP';

            :NEW.PROJECT_ID := v_number;      
         end if;

      INSERT INTO R_TRACKER (
         PROJECT_ID,
         PRO_LOC,
         DESIGNATION,
         NO_OF_POSITION,

2 个答案:

答案 0 :(得分:0)

因为你的触发器是递归触发器。您可以阅读this article

答案 1 :(得分:0)

你的触发器将进入无限循环,因为

  • 您已在R_TRACKER和
  • 上触发了行级插入触发器
  • 您正在插入同一个表R_Tracker

您可以发送完整的触发器代码吗?