各位大师,快帮帮忙呀,这个问题比较急,SQL SERVER 2000是支持这种触发器递归模式的,只需要设置SQL SERVER的参数就好了,相信ORACLE也是可以的,望高手帮忙,谢谢啦
我正好写了一个,和你的情况和类似 你可以参考一下 数据库是oracle10g 具体情况是当表sb_ckdpb的字段bill_state变成'1'的时候就把它字表sb_ckdxb的sl字段查询出来 并和其子表相一一对应的另一表sb_rkdxb的sl情况更新另一表sb_rkdxb 的字段sl create or replace trigger wz_kcslliu_sb_ckdpb after update of bill_state on sb_ckdpb for each row declare slck number; slrk number; begin if updating then if :new.BILL_STATE='1' and :old.bill_state!='1' then for m in (select sbbh from sb_ckdxb where bh=:new.bh) loop select nvl(sl,0) into slck from sb_ckdxb where sbbh=m.sbbh; select nvl(sl,0) into slrk from sb_rkdxb where sbbm=m.sbbh; update sb_rkdxb set sysl=slrk-slck where sbbm=m.sbbh; end loop; end if; end if; end wz_kcslliu_sb_ckdpb;
你可以参考一下
数据库是oracle10g
具体情况是当表sb_ckdpb的字段bill_state变成'1'的时候就把它字表sb_ckdxb的sl字段查询出来
并和其子表相一一对应的另一表sb_rkdxb的sl情况更新另一表sb_rkdxb 的字段sl
create or replace trigger wz_kcslliu_sb_ckdpb after update of bill_state on sb_ckdpb for each row
declare
slck number;
slrk number;
begin
if updating then
if :new.BILL_STATE='1' and :old.bill_state!='1' then
for m in (select sbbh from sb_ckdxb where bh=:new.bh)
loop
select nvl(sl,0) into slck from sb_ckdxb where sbbh=m.sbbh;
select nvl(sl,0) into slrk from sb_rkdxb where sbbm=m.sbbh;
update sb_rkdxb set sysl=slrk-slck where sbbm=m.sbbh;
end loop;
end if;
end if;
end wz_kcslliu_sb_ckdpb;