当前位置: 代码迷 >> Sql Server >> 同志们啊快帮小弟我看看这个触发器,如何每次出发完植都是空的!
  详细解决方案

同志们啊快帮小弟我看看这个触发器,如何每次出发完植都是空的!

热度:56   发布时间:2016-04-27 16:22:54.0
同志们啊,快帮我看看这个触发器,怎么每次出发完植都是空的!!
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   [email protected])
set   @dailiao_day_salary=(select   dlrx   from   ryda   where   [email protected])
SET   @total=(select   sum(sum_sigle)   from   jjjlb   where   [email protected]   and   [email protected]   and   [email protected]   )

update   jjjlb   set   sum_sigle=(@[email protected][email protected][email protected][email protected][email protected]_salary/208*zrbgs*2+yxb_a*2+yxb_a*3)  
where   [email protected]   and   [email protected]   and   [email protected]
update   jjjlb   set   [email protected]   where   [email protected]   and   [email protected]   and   [email protected]
fetch   next   from   cur_total   into   @rq,@bh,@ppo
end
close   cur_total
deallocate   cur_total


------解决方案--------------------
set @sub_salary=(select jbsx from ryda where [email protected])
set @dailiao_day_salary=(select dlrx from ryda where [email protected])
SET @total=(select sum(sum_sigle) from jjjlb where [email protected] and [email protected] and [email protected] )

--〉
set @sub_salary=isnull((select jbsx from ryda where [email protected]),0)
set @dailiao_day_salary=isnull((select dlrx from ryda where [email protected]),0)
SET @total=isnull((select sum(sum_sigle) from jjjlb where [email protected] and [email protected] and [email protected] ),0)


------解决方案--------------------

while (@@fetch_status <> -1)
改成
while (@@fetch_status=0)试试
------解决方案--------------------
把游标内的处理过程修改一下试试:
while(@@fetch_status = 0)
begin
select @sub_salary = isnull(jbsx,0), @dailiao_day_salary = isnull(dlrx,0)
from ryda where [email protected]
select @total = isnull(sum(sum_sigle),0)
from jjjlb where [email protected] and [email protected] and [email protected]

update jjjlb set
sum_sigle=(ISNULL(@sub_salary/208*jssj,0)[email protected]_salary/208*1.5+
ISNULL(@sub_salary/208*zlbgs,0)+
ISNULL(@sub_salary/208*jbsj_b*2,0)+
ISNULL(@sub_salary/208*zrbgs,0)+
ISNULL(@sub_salary/208*zrbgs*2,0)+
ISNULL(yxb_a*2,0)+
ISNULL(yxb_a*3,0))
where [email protected] and [email protected] and [email protected]
...
------解决方案--------------------
是青青嗎
------解决方案--------------------
現在在哪里啊
------解决方案--------------------
如果hellowork(一两清风)大哥,說的,改了沒用的話,
把FOR INSERT, UPDATE, DELETE
改為after INSERT, UPDATE, DELETE 試試
  相关解决方案