关于游标的一个问题

raindots 2004-02-24 08:16:50
declare @ii int
declare c1 cursor local for
select * from rpt_emp_khjl_bal where work_date = @work_date and emp_flag = '1' order by dg_ck_bal desc
for update

set @ii = 0
open c1

fetch next from c1
while @@FETCH_STATUS = 0
begin
set @ii = @ii + 1
update rpt_emp_khjl_bal set dg_ck_sdpm = @ii where current of c1

fetch next from c1
end

close c1
deallocate c1

我要实现的是根据dg_ck_bal 这个字段的降序实现一个排名

可在运行时报错
在 READ ONLY 游标上不能指定 FOR UPDATE。
应该如何解决呢
...全文
48 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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