--解决了,代码如下,请哪位高手给解释一下为何这样就可以了,而上面的就不行
alter trigger wei.tia_gft_yhgeda_temp after insert on
wei.GFT_YHGEDA_TEMP
referencing new as new_i
for each row begin
if new_i.c_state = 0 then
insert into GFT_BiaoDetail values(new_i.c_gebianhao,(select GFT_RANQIBIAO.c_no from GFT_RANQIBIAO where
GFT_RANQIBIAO.c_biaoxh = new_i.c_biaoxh and GFT_RANQIBIAO.c_biaocd = new_i.c_biaocd))
end if
end
老大,或者使用游标!!!
if new_ins.c_state = 0 then
c_Cur In( select c_no from GFT_RANQIBIAO where c_biaoxh = new_ins.c_biaoxh and c_biaocd = new_ins.c_biaocd ) Loop
insert into GFT_biaodetail values(new_ins.c_gebianhao,c_Cur.c_no)
End Loop
end if
原文:
alter trigger wei.tia_gft_yhgeda_temp after insert on
wei.GFT_YHGEDA_TEMP
referencing new as new_ins
for each row
begin
if new_ins.c_state = 0 then
select c_no from GFT_RANQIBIAO where c_biaoxh = new_ins.c_biaoxh and c_biaocd = new_ins.c_biaocd;
insert into GFT_biaodetail values(new_ins.c_gebianhao,GFT_RANQIBIAO.c_no)
end if
end
错误:
insert into GFT_biaodetail values(new_ins.c_gebianhao,GFT_RANQIBIAO.c_no)
^^^^^^^^^^^^^^^^^
end if
解决:
你应该把前面Select的C_No保存在一个变量中,然后在后面的Insert中使用该变量!!!