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

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
...全文
206 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
newqq 2007-07-09
  • 打赏
  • 举报
回复
是我啊亮亮,哈哈
newqq 2007-07-09
  • 打赏
  • 举报
回复
已经搞定了,谢谢大家啊:)
fa_ge 2007-07-03
  • 打赏
  • 举报
回复
如果hellowork(一两清风)大哥,說的,改了沒用的話,
把FOR INSERT, UPDATE, DELETE
改為after INSERT, UPDATE, DELETE 試試
fa_ge 2007-07-03
  • 打赏
  • 举报
回复
現在在哪里啊
fa_ge 2007-07-03
  • 打赏
  • 举报
回复
是青青嗎
hellowork 2007-07-03
  • 打赏
  • 举报
回复
把游标内的处理过程修改一下试试:
while(@@fetch_status = 0)
begin
select @sub_salary = isnull(jbsx,0), @dailiao_day_salary = isnull(dlrx,0)
from ryda where bh=@bh
select @total = isnull(sum(sum_sigle),0)
from jjjlb where bh=@bh and rq=@rq and ppo=@ppo

update jjjlb set
sum_sigle=(ISNULL(@sub_salary/208*jssj,0)+@sub_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 bh=@bh and rq=@rq and ppo=@ppo
...
hellowork 2007-07-03
  • 打赏
  • 举报
回复

while (@@fetch_status<>-1)
改成
while (@@fetch_status=0)试试
newqq 2007-07-03
  • 打赏
  • 举报
回复
怎么没人来回答啊,大家都在忙什么呢
newqq 2007-07-03
  • 打赏
  • 举报
回复
这样个也不对,而且所有字段都是有数据的
昵称被占用了 2007-07-02
  • 打赏
  • 举报
回复
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 )

--〉
set @sub_salary=isnull((select jbsx from ryda where bh=@bh),0)
set @dailiao_day_salary=isnull((select dlrx from ryda where bh=@bh),0)
SET @total=isnull((select sum(sum_sigle) from jjjlb where bh=@bh and rq=@rq and ppo=@ppo ),0)

34,587

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧