游標(biāo) 處女作
由于觸發(fā)器的原因,所以更新數(shù)據(jù)的時(shí)候經(jīng)常不能使用直接update來修復(fù)數(shù)據(jù)。所以試著去用游標(biāo)來更新
代碼
declare upduser scroll cursor
for
select aopp_userid from aopportunity
where aopp_userid <> aopp_createdby
and aopp_status ='ccfollowup'
and aopp_deleted is null
and aopp_userid is not null
for update
open upduser
declare @aopp_userid int
fetch from upduser into @aopp_userid
while @@fetch_status = 0
begin
if @aopp_userid is not null
--print @aopp_userid
update aopportunity set aopp_createdby = @aopp_userid,aopp_contractcounselor = @aopp_userid
where current of upduser
fetch from upduser into @aopp_userid
end
close upduser
deallocate upduser
作者:Novus
出處:http://www.rzrgm.cn/novus/
本文版權(quán)歸作者和博客園共有,歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處。


浙公網(wǎng)安備 33010602011771號(hào)