如下所示
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;

解决方案 »

  1.   

    触发器不可直接对主表进行操作——>update ar_info ...
      

  2.   

    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;
      

  3.   

    谢谢二位。我刚好也写了一个。不报错了。但是由于我一次提交了上千条数据,通过WebService提交的,结果提交时间太长,导致提交失败?有更好的办法吗?
    create or replace trigger Tri_Update_Barcode_ar_info
      before insert on ar_info  
      for each row
    declare
      -- local variables here
      --bar nvarchar2(15);
    begin
         select min(barcode) into :new.ar_barcode from SYS_BARCODE where is_used=0;      --把原表这个值的标志位置为1
         update SYS_BARCODE
         set IS_USED=1 
         where BARCODE=:new.ar_barcode;
         
         --将此值赋值给新值
         --update ar_info
         --set ar_barcode = bar 
         --where ar_id = :new.ar_id;end Tri_Update_Barcode_ar_info;