我可以重置光标的位置到开始吗?

编程入门 行业动态 更新时间:2024-10-27 06:31:32
本文介绍了我可以重置光标的位置到开始吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如主题。我可以简单地将光标的位置重置到Transact-SQL的开头,以便它可以再次在表上运行吗?我想在以下上下文中重置它: $ b $bÚ

As in the topic. Can I simply reset cursor's position to the beginning in Transact-SQL, so it can run again over the table? I want to reset it in the following context:

DECLARE @userID INT DECLARE user_cursor CURSOR FOR SELECT userID FROM users WHILE /* some condition */ BEGIN ... FETCH NEXT FROM user_cursor INTO @userID IF @@FETCH_STATUS = 0 BEGIN /*... here goes the reset of the cursor ...*/ END ... END

/ p>

thanx for any advice.

推荐答案

您需要将光标声明为滚动,如下所示

you need to declare your cursor as scroll, like this

declare c scroll cursor for (select statement);

然后在任何时候找到第一个只需使用以下

then at any time for locating to the first just use the following

fetch first from c;

更多推荐

我可以重置光标的位置到开始吗?

本文发布于:2023-07-20 05:09:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1164503.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标的   位置

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!