我收到语句的变异表错误insert into employee select 'xyz',200 from dual
,并且脚本成功执行insert into employee values ('abc',100);
。
有人可以解释为什么该语句对于一种类型的插入语句失败吗?两个脚本都将相似类型的数据插入到表中
脚本细节:
--table creation
create table employee (name varchar2(30),salary number);
--trigger creation
create or replace trigger emp_trig
before insert on employee
for each row
begin
delete from employee where name=:new.name;
end;
/
--insert statement 1
insert into employee values ('abc',100);
--result : 1 row inserted
--insert statement 2
insert into employee select 'xyz',200 from dual
--result:
Error report -
ORA-04091: table NMS_CON.EMPLOYEE is mutating, trigger/function may not see it
ORA-06512: at "NMS_CON.EMP_TRIG", line 2
ORA-04088: error during execution of trigger 'NMS_CON.EMP_TRIG'