触发器创建示例

create or replace trigger tri_ins_equ_posinfo
  after update or insert or delete on equ_posinfo
  for each row

begin
  if inserting then
   insert into equ_posinfo@GPSDB
    values  (:new.poscode, :new.barcode, :new.status, :new.isstandby,
    :new.materielid, :new.usetype, :new.deptcode, :new.schoolcode,
    :new.carcode, :new.accessid, :new.accesstime, :new.issueid,
    :new.issuetime, :new.progedition, :new.pramedtion, :new.kdedtion,
    :new.hostsoftver, :new.handsoftver);
  else if updating then
     update equ_posinfo@GPSDB s
      set s.barcode=:new.barcode,
          s.status=:new.status,
          s.isstandby=:new.isstandby,
          s.materielid=:new.materielid,
          s.usetype=:new.usetype,
          s.deptcode=:new.deptcode,
          s.schoolcode=:new.schoolcode,
          s.carcode=:new.carcode,
          s.accessid=:new.accessid,
          s.accesstime=:new.accesstime,
          s.issueid=:new.issueid,
          s.issuetime=:new.issuetime,
          s.progedition=:new.progedition,
          s.pramedtion=:new.pramedtion,
          s.kdedtion=:new.kdedtion,
          s.hostsoftver=:new.hostsoftver,
          s.handsoftver=:new.handsoftver
        where s.poscode = :old.poscode;
    else if deleting then
       delete from equ_posinfo@GPSDB s
         where s.poscode = :old.poscode;
      end if;
    end if;
  end if;
end;

你可能感兴趣的:(delete,insert,each)