不是,oracle触发器中的SQL语句不容许查询或修改触发语句的变化表。变化表:指当前被update、delete、insert等触发语句修改的数据库表,或者完整性约束等的表。不过可以变通一下,不要用update语句,写成: before update ... :new_testll:='d'的形式。
请参考: CREATE OR REPLACE TRIGGER trig_insert_tsc BEFORE INSERT ON cn_r_tsc REFERENCING NEW AS new_tsc FOR EACH ROW DECLARE pptsc NUMBER; BEGIN pptsc:=1; :new_tsc.tsc:=pptsc; END;
把触发器该成这样: create or replace trigger tri_test11 after update of a on test11 for each row begin :new.b :='d'; end;
ORA-04091 table name is mutating, trigger/function may not see itCause A trigger or a user-defined PL/SQL function that is referenced in the statement attempted to query or modify a table that was in the middle of being modified by the statement that fired the trigger. Action Rewrite the trigger or function so it does not read the table.
sorry上面的不对: create or replace trigger tri_test11 before update of a on test11 for each row begin :new.b :='d'; end;
CREATE OR REPLACE TRIGGER trig_insert_tsc
BEFORE INSERT
ON cn_r_tsc
REFERENCING NEW AS new_tsc
FOR EACH ROW
DECLARE
pptsc NUMBER;
BEGIN
pptsc:=1;
:new_tsc.tsc:=pptsc;
END;
create or replace trigger tri_test11 after update of a on test11
for each row
begin
:new.b :='d';
end;
Action Rewrite the trigger or function so it does not read the table.
create or replace trigger tri_test11 before update of a on test11
for each row
begin
:new.b :='d';
end;