sql中简单触发器案例

来源:互联网 发布:普通专升本网络课程 编辑:程序博客网 时间:2024/05/21 09:32
create trigger tri_zl_lx
on ZL_LX  for update
as
if update(ZL_lx_score)
begin
update ZG_ZL
set  ZG_ZL.Score4=inserted.ZL_lx_score*CG_JS.xi_shu
from   inserted,ZG_ZL,ZL,CG_JS
where  ZG_ZL.ZL_id=ZL.ZL_id  and  ZL.ZL_lx_id=inserted.ZL_lx_id   and CG_JS.rank=ZG_ZL.F_G4 and CG_JS.num=ZL_rs

end




create trigger tri_z_lb
on Z_LB  for update
as
if update(Z_LB_score)
begin
update ZG_Z_ZUO
set  ZG_Z_ZUO.Score3=inserted.Z_LB_score*CG_JS.xi_shu *Z_ZUO.Z_words
from   inserted,ZG_Z_ZUO,Z_ZUO,CG_JS
where  ZG_Z_ZUO.Z_id=Z_ZUO.Z_id  and  Z_ZUO.Z_LB_id=inserted.Z_LB_id   and CG_JS.rank=ZG_Z_ZUO.F_G3 and CG_JS.num=Z_ZUO.z_rs
end




create trigger tri_sl
on SL  for update
as
if update(SL_score)
begin
update ZG_LW
set  ZG_LW.Score=(inserted.SL_score+KW_score)*CG_JS.xi_shu
from  KW_JB ,inserted,ZG_LW,L_W,CG_JS
where  ZG_LW.LW_id=L_W.LW_id  and  L_W.KW_id=KW_JB.KW_id and L_W.SL_id=inserted.SL_id  and CG_JS.rank=ZG_LW.F_G and CG_JS.num=LW_rs
end


原创粉丝点击