Oracle触发器修改同一表不同字段


比如说当表A的一个insert,update的操作,然后自动把表A的相关字段update为一个值,但是这样就会造成死循环,如何只让触发器只执行一次。

create trigger biufer_employees_department_id
      before insert or update
              of department_id
              on employees
      referencing old as old_value
                      new as new_value
      for each row
      when (new_value.department_id <>80 )
begin
      :new_value.commission_pct :=0;
end;

    这种自身触发只能修改 :new_value.commission_pct,我如果想修改某特定行的数据,需要加限制条件的,如果处理。加WHERE…?不太明白楼主想要表达什么意思
如果要修改当前记录的值,条件在when里面控制就好了
如果是要修改非当前记录的其他特定记录的值,要改成表级触发器或者使用自治事务了如果不是要修改本行,改成表级触发器。<
<
这样在触发器中操作同一个触发表的表是不是叫“变异表”哟!以前好像在那里看见过关于变异表的概验。要用自治事物。
pragma autonomous_transaction;<
不能改成表触发器,因为我还得使用OLD NEW。我使用了自治事务,但是编译不过去。提示pragma autonomous_transaction cannot be declared here CREATE OR REPLACE TRIGGER trig_ac30_AAE008
  AFTER insert or update of  AAE008
  ON AAE008_UPDATE
  for each row
when (OLD.AAE008 <> NEW.AAE008)
BEGIN
declare
pragma autonomous_transaction;

begin
  update ac30
    set AAE008=:NEW.AAE008, aae010=:NEW.aae010
  where AAC001 =:NEW.AAC001
  AND AAE140='32';
  commit;
  end;
END;
有错误吗?if inserting or  updating('depatime')  then 

当修改 depatime 字段值的时候触发,修改其他字段的时候不触发

相关内容