可更新游标的一个问题.总是说我的是for read Only.为什么???

Kassis78 2005-11-18 08:46:21
源代码如下:
CREATE PROCEDURE [My_UpdateID] AS
declare @id_s varchar
declare @id_s_val varchar(1)
declare @id decimal (10,0)
--定义五个需要的变量
declare @StarOfID bigint --单号的开始数字
declare @IdOfRow int --每页的行号

------------------------------------------------
set @StarofID =5120000 --单号的初始值100000六位
set @IDofRow =00

declare MyCursor Cursor for
select id_s from Inventory_Table order by sbu for update of id_s
open MyCursor
while (0=0)begin
while (@IDOfRow<10)begin
fetch MyCursor INTO @ID_s
-------------------------------------------------------------
if (@id_s_val=@Id_s) begin
update inventory_table set id_s=@starofid +@idofrow where current of mycursor
end

else begin
--set @IDofRow=01
set @StarOfID=@StarOfID+1
update inventory_table set id_s=@StarOfID +@idofrow where current of mycursor
end
if (@@fetch_status<>0) break
set @Id_s_val=@Id_s
set @IDofRow=@IDofRow+1
print '正在填充第'+cast(@idofrow as varchar)+'行!'
end
set @IDofRow=0
end
close MyCursor
deallocate MyCursor
GO
里面我已经尝试过用很多的参数,如:scroll_locks ,dynamic...等等,可是它就是说我:
'服务器: 消息 16957,级别 16,状态 4,过程 My_UpdateID,行 14
在 READ ONLY 游标上不能指定 FOR UPDATE。'
为什么啊?那位高手帮我解决这个问题???
...全文
175 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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