create or replace trigger TI_JHZB_update
  after update on dzcg_jhd_zb
  for each row
declare
 jhd_zb dzcg_jhd_zb %rowtype;
begin
  select * into jhd_zb from  dzcg_jhd_zb  where id=:old.ID;
  if :new.jhsh='1' or :new.jhsh='2' then
    update dzcg_jhd_zb set jhzf='1' where id=:old.ID;
   elsif :new.jhsh='0' then
    update dzcg_jhd_zb set jhzf='0' where id=:old.ID;
  end if;
end TI_JHZB_update;插一条记录审核和作废两个状态都是null 或 0
如过jhsh 该成了1 或 2  就把 jhzf该成 1
如过jhsh 该成了0  就把 jhzf该成 0

解决方案 »

  1.   

    --先创建一个表的备份才行,如:create table dzcg_jhd_zb_bak as select * from dzcg_jhd_zb where 1=1;create or replace trigger TI_JHZB_update 
      after update on dzcg_jhd_zb_bak    --在这张表上进行操作,然后映射到dzcg_jhd_zb上。
      for each row 
    declare 
    jhd_zb dzcg_jhd_zb %rowtype; 
    begin 
      select * into jhd_zb from  dzcg_jhd_zb  where id=:old.ID; 
      if :new.jhsh='1' or :new.jhsh='2' then 
        update dzcg_jhd_zb set jhzf='1' where id=:old.ID; 
      elsif :new.jhsh='0' then 
        update dzcg_jhd_zb set jhzf='0' where id=:old.ID; 
      end if; 
    end TI_JHZB_update; --对不起,还是憋不住要和楼主开个玩笑:
    --有曰张飞:汝力大,能提已之头发离地否?  :-)
      

  2.   

    可以这样来的:
    create or replace trigger TI_JHZB_update
    before update on dzcg_jhd_zb
    for each row
    begin
    if :new.jhsh='1' or :new.jhsh='2' then
    :new.jhzf:='1';
    elsif :new.jhsh='0' then
    :new.jhzf:='0';
    end if;
    end;
    /
      

  3.   

    语法好多不对create or replace trigger TI_JHZB_update
      before update on dzcg_jhd_zb
      for each row
    begin
      if :new.jhsh = '1' or :new.jhsh = '2' then
    :new.jhzf := '1';
      elsif :new.jhsh = '0' then
         :new.jhzf := '0';
      end if;
    end TI_JHZB_update;