首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

超简单Trigger,求救,该怎么解决

2012-01-01 
超简单Trigger,求救如下所示createorreplacetriggerTri_Update_Barcode_ar_infoafterinsertonar_infoforea

超简单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;

热点排行