同志们啊,快帮我看看这个触发器,怎么每次出发完植都是空的!!
newqq 2007-07-02 08:06:35 alter TRIGGER sum_gz ON [dbo].[jjjlb]
FOR INSERT, UPDATE, DELETE
AS
declare @dailiao_day_salary float
declare @sub_salary float
declare @total float
declare cur_total cursor for
select rq,bh,ppo from inserted
open cur_total
declare @rq varchar(10)
declare @bh varchar(50)
declare @ppo varchar(50)
fetch next from cur_total into @rq,@bh,@ppo
while (@@fetch_status<>-1)
begin
set @sub_salary=(select jbsx from ryda where bh=@bh)
set @dailiao_day_salary=(select dlrx from ryda where bh=@bh)
SET @total=(select sum(sum_sigle) from jjjlb where bh=@bh and rq=@rq and ppo=@ppo )
update jjjlb set sum_sigle=(@sub_salary/208*jssj+@sub_salary/208*1.5+@sub_salary/208*zlbgs+@sub_salary/208*jbsj_b*2+@sub_salary/208*zrbgs+@sub_salary/208*zrbgs*2+yxb_a*2+yxb_a*3)
where bh=@bh and rq=@rq and ppo=@ppo
update jjjlb set total=@total where bh=@bh and rq=@rq and ppo=@ppo
fetch next from cur_total into @rq,@bh,@ppo
end
close cur_total
deallocate cur_total