日期:2014-05-17  浏览次数:20730 次

超简单Trigger,求救
如下所示
create   or   replace   trigger   Tri_Update_Barcode_ar_info
    after   insert   on   ar_info    
    for   each   row
declare
    --   local   variables   here
    bar   nvarchar2(15);
begin
          select   min(barcode)   into   bar   from   SYS_BARCODE   where   is_used=0;  

          --将此值赋值给新值
          update   ar_info
          set   ar_barcode   =   bar  
          where   ar_id   =   :new.ar_id;--报错位置

          --commit;
end   Tri_Update_Barcode_ar_info;

------解决方案--------------------
触发器不可直接对主表进行操作——> update ar_info ...
------解决方案--------------------
create or replace trigger Tri_Update_Barcode_ar_info
before insert on ar_info
for each row
begin
select min(barcode) into :new.ar_barcode from SYS_BARCODE where is_used=0;
end Tri_Update_Barcode_ar_info;