请帮忙解决游标问题
DECLARE @a int,@b intDECLARE abc CURSOR FOR
SELECT roomno,sitno FROM aa where xxcode=@xxcode and nj_c=@nj_c order by randshu --带有order by
--出错,提示游标是 READ ONLY 的。语句已终止。没有order by 则正常,但我要对随机数据进行排序来编排,请帮忙
--for update of roomno,sitno
OPEN abc
FETCH NEXT FROM abc
select @a=1,@b=0
WHILE (@@FETCH_STATUS = 0)
begin
begin
if @b>=@shu
select @a=@a+1, @b=0,@b=@b+1
else
set @b=@b+1
end
update aa set roomno=@a,sitno=@b where current of abc
FETCH NEXT FROM abc
end
CLOSE abc
DEALLOCATE abc
GO