我写了个触发器。目的就是在PO表中更新或者插入操作之前触发,插入或者更新到HTZXQK表中,但是有问题,我不知道处在那里了,请高手们帮忙看看,小弟在此谢过,
create or replace trigger "update_htzxqk"
before insert or update or delete
on "PO"
for each row 
 begin           if inserting then              insert into HTZXQK(xmbh,htbh) select po.jhbh,po.htbh from po          elsif updating then            update HTZXQK set htbh=po.htbh,xmbh=po.xmbh where htbh=htzxqk.htbh         
          end if;   end;  

解决方案 »

  1.   

    错误信息如下:
    发生编号:4098的数据库错误。
    请与系统管理员联系寻求帮助。ORA-04098:触发器'MAXIMO.PO_T_INSERT'无效且未通过验证
      

  2.   

    create or replace trigger "update_htzxqk" 
    before insert or update or delete 
    on "PO" 
    for each row  
     begin            if inserting then               insert into HTZXQK(xmbh,htbh) select new.jhbh,new.htbh from po           elsif updating then             update HTZXQK set htbh=new.htbh,xmbh=new.xmbh where htbh=new.htbh           
              end if;    end;
    这样改下看看
      

  3.   

    CREATE OR REPLACE TRIGGER "MAXIMO"."WX_UPDATE" AFTER
    INSERT
    OR UPDATE
    OR DELETE ON "PO" FOR EACH ROW begin
     case
     when inserting then
     insert into HTZXQK (xmbh,htbh) values (: new .jhbh,: new .htbh);
     end case ;
    end ;帮忙看看吧,小弟刚用ORACLE1天根本不会,时间不允许让我去看书,只能看点语法凑合写出来。帮帮忙吧
      

  4.   

      if inserting then     insert into niu_b(row_id,col1,col2) --select col1,col2 from niu_a ;
    VALUES(:new.row_id,:new.col1, :new.col2);  elsif updating then   update niu_b set col1=:new.col1,col2=:new.col2 where row_id =:new.row_id;
      end if;
      

  5.   

    CREATE OR REPLACE TRIGGER "MAXIMO"."WX_UPDATE" AFTER 
    INSERT 
    OR UPDATE 
    OR DELETE ON "PO" FOR EACH ROW begin 
     case 
     when inserting then 
     insert into HTZXQK (xmbh,htbh) values (: new .jhbh,: new .htbh); 
     end case ; 
    end ; 改成这样看看CREATE OR REPLACE TRIGGER "WX_UPDATE" AFTER 
    INSERT 
    OR UPDATE 
    OR DELETE ON PO FOR EACH ROW
    begin 
      if inserting then 
         insert into HTZXQK (xmbh,htbh) values (:new.jhbh,:new.htbh); 
      --elsif updating then 
       --update niu_b set col1=:new.col1,col2=:new.col2 where row_id =:new.row_id; 
      end;
    end ;
      

  6.   

    create or replace trigger "update_htzxqk"
    before insert or update or delete
    on APPS.niu_a
    for each row
    begin
      if inserting then
         insert into niu_b(row_id,col1,col2) --select col1,col2 from niu_a ;
    VALUES(:new.row_id,:new.col1, :new.col2);
      elsif updating then
       update niu_b set col1=:new.col1,col2=:new.col2 where row_id =:new.row_id;
      end if;
    end;
    参照一下把
      

  7.   

    大哥你的题目里写的这个xmbh,htbh
    害死人阿。全角逗号阿~
      

  8.   

    create or replace trigger "update_htzxqk"  
    before insert or update or delete  
    on "PO" 
    REFERENCING OLD AS OLD NEW AS NEW 
    for each row   
     begin             if inserting then                insert into HTZXQK(xmbh,htbh) select new.jhbh,new.htbh from dual            elsif updating then              update HTZXQK set htbh=new.htbh,xmbh=new.xmbh where htbh=new.htbh             
              end if;     end;