CREATE OR REPLACE TRIGGER MSG.uppurworkbuyer
  AFTER INSERT
  on "MSG"."HOLA_APP_NT_PURWORK"
  for each row
begin
    if BUYER is null
        update table HOLA_APP_NT_PURWORK 
        set BUYER = 
            (select ORG_CODE from org_position where emp_id = (select REQEMPID from HOLA_APP_NT_PURREQ where REQID =:OLD.REQID ))
        where PURWORKID =:OLD.PURWORKID 
    end if
end;生成触发器之后有一个警告:
PLS-00103: 出现符号 "UPDATE"在需要下列之一时: then and or
@@ 一直没有搞定 请大家帮忙看看啊

解决方案 »

  1.   

    CREATE OR REPLACE TRIGGER MSG.uppurworkbuyer
      AFTER INSERT
      on "MSG"."HOLA_APP_NT_PURWORK"
      for each row
    begin
        if BUYER is null then
            update table HOLA_APP_NT_PURWORK 
            set BUYER = 
                (select ORG_CODE from org_position where emp_id = (select REQEMPID from HOLA_APP_NT_PURREQ where REQID =:OLD.REQID ))
            where PURWORKID =:OLD.PURWORKID 
        end if
    end;
      

  2.   

    CREATE OR REPLACE TRIGGER MSG.uppurworkbuyer
      AFTER INSERT
      on MSG.HOLA_APP_NT_PURWORK
      for each row
    begin
        if :old.BUYER is null then
            update HOLA_APP_NT_PURWORK 
            set BUYER = 
                (select ORG_CODE from org_position where emp_id = (select REQEMPID from HOLA_APP_NT_PURREQ where REQID =:OLD.REQID ))
            where PURWORKID =:OLD.PURWORKID;
        end if;
    end;
      

  3.   


    CREATE OR REPLACE TRIGGER MSG.uppurworkbuyer
      AFTER INSERT
      on "MSG"."HOLA_APP_NT_PURWORK"
      for each row
    begin
        if BUYER is null then --不是提示你少 then了吗
            update table HOLA_APP_NT_PURWORK 
            set BUYER = 
                (select ORG_CODE from org_position t where exists (select 1 from HOLA_APP_NT_PURREQ where t.emp_id=REQEMPID and  REQID =:OLD.REQID ))
            where PURWORKID =:OLD.PURWORKID ;
        end if;
    end;
      

  4.   


    PLS-00103: 出现符号 "UPDATE"在需要下列之一时: then and orif BUYER is null then  where PURWORKID =:OLD.PURWORKID ;
        end if;
      

  5.   

    CREATE OR REPLACE TRIGGER MSG.uppurworkbuyer
      AFTER INSERT
      on "MSG"."HOLA_APP_NT_PURWORK"
      for each row
    begin
        if :new.BUYER is null
            update table HOLA_APP_NT_PURWORK 
            set BUYER = 
                (select ORG_CODE from org_position where emp_id = (select REQEMPID from HOLA_APP_NT_PURREQ where REQID =:new.REQID ))
            where PURWORKID =:new.PURWORKID 
        end if
    end;insert类型的trigger :old没意义的.
      

  6.   


    if BUYER is null then  where PURWORKID =:new.PURWORKID ;
      end if;