工大后院

 找回密码
 加入后院

扫一扫,访问微社区

QQ登录

只需一步,快速开始

搜索
查看: 2686|回复: 2

使用游标update为什么不能用order by?

[复制链接]
发表于 2009-1-11 14:16 | 显示全部楼层 |阅读模式
大家好
我使用游标来修改数据
发现select中有order by 语句的话,会提示游标是只读的
搜索了一下,说拿掉order by就好了,但没说原因
请问是什么原因?

sql是这样写的:

declare test cursor for
select id,hshf_id from gwh where (id is  null) and (hshf_id is not null) and (nianfen='2008') '这里再加order by就会报错
open test
declare @idno int, @idno1 int
fetch next from test
into @idno,@idno1
while(@@fetch_status=0)
begin
if(@idno1<370 and @idno1>0)
update gwh set id = hshf_id +5000
where current of test
fetch next from test
into @idno,@idno1
end
close test
deallocate test
头像被屏蔽
发表于 2009-1-21 16:55 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

发表于 2009-2-15 11:48 | 显示全部楼层
有order by 一样可以的,应该是你的表没有建主建的原因。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入后院

本版积分规则

QQ|Archiver|手机版|小黑屋|广告业务Q|工大后院 ( 粤ICP备10013660号 )

GMT+8, 2024-6-2 22:47

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表