:old.列名 作为一个已知的数值

解决方案 »

  1.   

    ^_^>>create table A(id int);
    表已创建。
    ^_^>>insert into A values(1);
    已创建 1 行。
    ^_^>>create table B(id int);
    表已创建。  1  CREATE OR REPLACE TRIGGER tg_af_update
      2    AFTER UPDATE ON A FOR EACH ROW
      3  DECLARE
      4         Bid NUMBER(4):=:old.id;
      5  BEGIN
      6       INSERT INTO B(id) VALUES (Bid);
      7* END;
    触发器已创建^_^>>update A set id=2 where id=1;
    已更新 1 行。
    ^_^>>select * from A;
            ID
    ----------
             2
    ^_^>>select * from B;
            ID
    ----------
             1
      

  2.   

    create or trigger name_tir
    before update on table
    for each row 
    begin
    --不存在记录
    insert into 表名 (col1,...) values (:old.col1,.....);
    --原来存在记录
    update 表名 set col1=:old.col1 where 表名.id=:old.id;
    end;
    end name_tir;
      

  3.   

    修改前头为:create or replace trigger name_tir