请问存储过程中对于两层循环的游标, 条件while @@fetch_status = 0 在内、外层一样的用有没有冲突?

wh1977 2008-01-09 09:14:51
declare cur1 cursor local fast_forward for select ....
open cur1
fetch next from cur1 into ...


while @@fetch_status = 0
------------开始循环1------------------------
begin


declare cur2 cursor local fast_forward for select ....
open cur2
fetch next from cur2 into ...


while @@fetch_status = 0
------------开始循环2------------------------
begin


end


end
...全文
282 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
昵称被占用了 2008-01-09
  • 打赏
  • 举报
回复
只要保证
while @@fetch_status = 0
在正确的
fetch next ...
后执行

就没问题
wzy_love_sly 2008-01-09
  • 打赏
  • 举报
回复
上个fetch的

34,590

社区成员

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

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