我想可以用after update for each row.

解决方案 »

  1.   

    CREATE OR REPLACE TRIGGER demotr
      BEFORE UPDATE OF isfin
      ON a
      FOR EACH ROW
    BEGIN
      IF :new.isfin = 1 and :old.isfin = 0 THEN
      insert into e select c.user_code,c.isinu,d.fin_time,sysdate from c,d where c.f_code = :new.f_code and c.f_ins = :new.f_ins and d.f_code = :new.f_code and d.f_ins = :new.f_ins;
      END IF;
    END demotr;
    /
    你试试行不行
      

  2.   

    把上面的BEFORE UPDATE 改成after update
      

  3.   

    CREATE OR REPLACE TRIGGER yourtrgname
      AFTER UPDATE OF isfin
      ON a
      FOR EACH ROW
    BEGIN
      IF :new.isfin = 1 and :old.isfin = 0 THEN
      insert into e select c.user_code,c.IsInU,d.fin_time,sysdate from c,d where c.f_code = :old.f_code and c.f_ins = :old.f_ins and d.f_code = :old.f_code and d.f_ins = :old.f_ins;
      END IF;
    END yourtrgname;
    这里不知道Scrate对于关联字段的修改时怎么处理,所以我觉得是否用:old比较好。
    ^o^
      

  4.   

    create or replace trigger auto_check
    after update on a
    for each row
    declare
      c_user_code c.user_code%type;
      c_IsInU c.IsInU%type;
      d_fin_time d.fin_time%type;
    begin
      if :new.IsFin=1 and :old.IsFin=0
      then
        /*根据a表的f_code和f_ins字段,把c表的相应记录的user_code,IsInU字段和d表中相应记录的fin_time字段,记录到对应的变量中去。*/
        insert into e values(c_user_code,c_IsInU,d_fin_time,sysdate);
      end if;
    end;
      

  5.   

    请问,插入表e的时候,不用像其他insert语句那样写成
    insert into 表名 (列名)    values(值)
    如果写成这样,values中的值怎么写呀
      

  6.   

    insert into 表名 (列名)select 列名1,列名2... from 表名2 where...;
      

  7.   

    报错,ora_004074:无效referencing名称
      

  8.   

    吧你执行的语句,以及show error查出的出错信息都贴出来
      

  9.   

    我是在dba studio里写的,语句如下,定完新建触发器相应计时中定义完列更新后,触发器主体中的语句如下:
    declare 
    usercode NUMBER(10);   
    begin
      select user_code
      into usercode
      from r_accept_task_13
      where r_accept_task_13.node_code = :new.node_code 
         and r_accept_task_13.flow_code = :new.flow_code;
      insert into sh_message(user_code,isfinish,exp_time,flow_name,n_time) values('usercode','0','30','超期请求',sysdate);
    end;