-3
好的我發現下面的代碼是由其他人在文件中寫的。我的問題是,我想與更新光標,你必須有「FOR UPDATE OF」或「WHERE CURRENT OF」的地方在語法MSSQL更新沒有「FOR UPDATE OF」語法問題的遊標
set @group_id_new = (select max(group_id) + 1 from x_dc_multgroups_stage001c)
declare cur_cont cursor for
(select cont_id from x_dc_multgroups_stage002b)
open cur_cont
fetch next from cur_cont into @cont_id
while @@fetch_status = 0
begin
--print @cont_id
update x_dc_multgroups_stage002a
set group_id_new = @group_id_new
where group_id in (select group_id from x_dc_multgroups_stage002a where cont_id = @cont_id)
set @group_id_new = @group_id_new + 1
fetch next from cur_cont into @cont_id
end
close cur_cont
deallocate cur_cont
但是,遊標未被更新。它是如何工作的?我看不出爲什麼不,但你有機會知道。我們沒有你的模式或數據。 – Jodrell
我只是以爲你不能使用更新遊標,而無需在代碼中添加FOR UPDATE OF ..我不確定! – Callum
哦,好吧謝謝你達米安! :) – Callum