我有两个表:project
和postponedproject
更新了duedate
中的project
之后,我创建了三个触发器:change_project_duedate
和postponedproject_status
和postponedproject_difference
第一个是将旧的和更新的duedate
和项目表主键prono
移到postponedproject
表中:
create or replace trigger change_project_duedate
after update of duedate on project
for each row
begin
insert into postponedproject (Prono, oldduedate, newduedate, status, difference, reason)
values (:old.prono, :old.duedate, :new.duedate, null, null, null);
end;
第二个是查看newduedate
是否晚于旧oldduedate
,然后将值放入postponedproject.status
:
create or replace trigger postponedproject_status
before insert on postponedproject
for each row
declare
differencestatement postponedproject.status%type;
begin
if :new.newduedate > :new.oldduedate then
differencestatement := 'Project has been delayed';
Else
differencestatement := 'Project has been scheduled to finish eariler';
end if;
insert into postponedproject (status)
values (differencestatement);
end;
第三个是在difference
表中的oldduedate
和newduedate
之间放置值postponedproject
:
create or replace trigger postponedproject_difference
before insert on postponedproject
for each row
begin
:new.difference := :new.newduedate - :new.oldduedate;
end;
但是,当我更新项目表中的duedate
时,它给了我这样的错误:
Error report -
ORA-00036: maximum number of recursive SQL levels (50) exceeded
ORA-06512: at "21363937.POSTPONEDPROJECT_STATUS", line 9
ORA-04088: error during execution of trigger '21363937.POSTPONEDPROJECT_STATUS'
ORA-06512: at "21363937.POSTPONEDPROJECT_STATUS", line 9
ORA-04088: error during execution of trigger '21363937.POSTPONEDPROJECT_STATUS'
ORA-06512: at "21363937.POSTPONEDPROJECT_STATUS", line 9
ORA-04088: error during execution of trigger '21363937.POSTPONEDPROJECT_STATUS'
ORA-06512: at "21363937.POSTPONEDPROJECT_STATUS", line 9
ORA-04088: error during execution of trigger '21363937.POSTPONEDPROJECT_STATUS'
ORA-06512: at "21363937.POSTPONEDPROJECT_STATUS", line 9
ORA-04088: error during execution of trigger '21363937.POSTPONEDPROJECT_STATUS'
ORA-06512: at "21363937.POSTPONEDPROJECT_STATUS", line 9
ORA-04088: error during execution of trigger '21363937.POSTPONEDPROJECT_STATUS'
ORA-06512: at "21363937.POSTPONEDPROJECT_STATUS", line 9
ORA-04088: error during execution of trigger '21363937.POSTPONEDPROJECT_STATUS'
ORA-06512: at "21363937.POSTPONEDPROJECT_STATUS", line 9
ORA-04088: error during execution of trigger '21363937.POSTPONEDPROJECT_STATUS'
ORA-06512: at "21363937.POSTPONEDPROJECT_STATUS", line 9
ORA-04088: error during execution of trigger '21363937.POSTPONEDPROJECT_STATUS'
ORA-06512: at "21363937.POSTPONEDPROJECT_STATUS", line 9
ORA-04088: error during execution of trigger '21363937.POSTPONEDPROJECT_STATUS'
ORA-06512: at "21363937.POSTPONEDPROJECT_STATUS", line 9
ORA-04088: error during execution of trigger '21363937.POSTPONEDPROJECT_STATUS'
ORA-06512: at "21363937.POSTPONEDPROJECT_STATUS", line 9
ORA-04088: error during execution of trigger '21363937.POSTPONEDPROJECT_STATUS'
ORA-06512: at "21363937.POSTPONEDPROJECT_STATUS", line 9
ORA-04088: error during execution of trigger '21363937.POSTPONEDPROJECT_STATUS'
ORA-06512: at "21363937.POSTPONEDPROJECT_STATUS", line 9
ORA-04088: error during execution of trigger '21363937.POSTPONEDPROJECT_STATUS'
ORA-06512: at "21363937.POSTPONEDPROJECT_STATUS", line 9
ORA-04
如果有人可以帮我,我真的很感激。非常感谢
答案 0 :(得分:1)
您在表postponedproject_status
上的触发器postponedproject
在表postponedproject
上执行插入。这将导致触发器触发。它将在postponedproject
中插入一条记录。这将导致触发器触发。直到您达到五十级递归为止。
除了执行INSERT之外,您只需要对:NEW命名空间进行分配即可。
此外,您不需要两个触发器。舍弃postponedproject_difference
并将任务分配到另一个触发器中:
create or replace trigger postponedproject_status
before insert on postponedproject
for each row
declare
differencestatement postponedproject.status%type;
begin
:new.difference := :new.newduedate - :new.oldduedate;
if :new.newduedate > :new.oldduedate then
differencestatement := 'Project has been delayed';
Else
differencestatement := 'Project has been scheduled to finish eariler';
end if;
:new.status := differencestatement;
end;
可能您应该给它一个更通用的名称。