oracle的一个简单的触发器

create or replace trigger TRG_TZ_XS_KouYaCaiQingDan
---台账扣押财务触发器(刑事子表)
  after insert or update on xs_kouyawupinqingdan
  for each row
declare
begin
  if inserting then
           insert into tz_kouya_caiwudjbiao t
                   (
                    XJ_ID,
                    iidd,
                    anjianid,--案件编号
                    WuPin,--物品
                    ShuLiang,--数量
                    SheAnQingKuang,--涉案情况
                    WuPinBH,--物品编号
                    MuLuHao--目录号
                   )
                   values
                   (
                    :new.xj_id,
                    get_guid(sys_guid()),
                    :new.anjianid,
                    :new.MingCheng,
                    :new.ShuLiang,
                    fun_tz_getSheAnQingKuan(:new.anjianid,'刑事'),--获取涉案情况
                    :new.iidd,
                    :new.muluhao

                   );

  end if;
  if updating then
     update tz_kouya_caiwudjbiao s
     set
         WuPin=:new.MingCheng,--物品
         ShuLiang=:new.ShuLiang,--数量
         SheAnQingKuang=fun_tz_getSheAnQingKuan(:new.anjianid,'刑事')--涉案情况
     where
          s.WuPinBH=:old.iidd;
  end if;
end;

你可能感兴趣的:(oracle)