create trigger zfjhgl on jhgl
for insert
as
begin
declare @lhsl 类型,
@sph 类型
select @sph=sph from inserted
select @lhsl=lhsl from inserted where spmx.spbh=@sph
update spmx
set kcl=kcl+@lhsl
where spbh in (select sph from jhgl)insert jhgl(sph,lhsl,ghs,ysr)
select a.sph,a.lhsl,a.ghs,a.ysr from jhgl
where sph=@sph
and sph not in (select lhsl from jhgl)
end你再试试!
for insert
as
begin
declare @lhsl 类型,
@sph 类型
select @sph=sph from inserted
select @lhsl=lhsl from inserted where spmx.spbh=@sph
update spmx
set kcl=kcl+@lhsl
where spbh in (select sph from jhgl)insert jhgl(sph,lhsl,ghs,ysr)
select a.sph,a.lhsl,a.ghs,a.ysr from jhgl
where sph=@sph
and sph not in (select lhsl from jhgl)
end你再试试!
create trigger zfjhgl on jhgl
for insert
as
begin
declare @lhsl 类型,
@sph 类型
select @sph=sph from inserted
select @lhsl=lhsl from inserted
update spmx
set kcl=kcl+@lhsl
where spbh=@sph and spbh in (select sph from jhgl)insert jhgl(sph,lhsl,ghs,ysr)
select a.sph,a.lhsl,a.ghs,a.ysr from jhgl
where sph=@sph
and sph not in (select lhsl from jhgl)
end
可惜不知道你的具体的表结构以及数据类型,没法测试了。
我的意思是直接运用updated和inserted
这样行吗??