可更新游标的一个问题.总是说我的是for read Only.为什么???
源代码如下:
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。'
为什么啊?那位高手帮我解决这个问题???