我有一个在表中插入新记录时触发的触发器,因为我想在同一个表中插入新记录。
我的触发器是:
create or replace trigger inst_table
after insert on test_table referencing new as new old as old
for each row
declare
df_name varchar2(500);
df_desc varchar2(2000);
begin
df_name := :new.name;
df_desc := :new.description;
if inserting then
FOR item IN (SELECT pid FROM tbl2 where pid not in(1))
LOOP
insert into test_table (name,description,pid) values(df_name,df_desc,item.pid);
END LOOP;
end if;
end;
它给出一个错误,比如
ORA-04091: table TEST_TABLE is mutating, trigger/function may not see it
我认为它阻止我插入同一张桌子。
那么如何将这条新记录插入到同一张表中。
注意:- 我使用Oracle 作为数据库