有关游标的问题!!!

wallis 2003-08-09 02:34:33
当执行
declare a_cur scroll cursor
for
select col1 from tb1
open a_cur

服务器: 消息 16916,级别 16,状态 1,行 4
名为 'a_cur' 的游标不存在。

而只执行
declare a_cur scroll cursor
for
select col1 from tb1
时成功

而且我用
deallocate a_cur
也成功


请问是什么原因?
...全文
23 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
pengdali 2003-08-09
  • 打赏
  • 举报
回复
你试试呢?

declare a_cur scroll cursor for select * from pubs..jobs
open a_cur

deallocate a_cur
zjcxc 元老 2003-08-09
  • 打赏
  • 举报
回复
刚才去试了,sql7.0也没有问题.

楼主最好将全部语句贴出.
sdhdy 2003-08-09
  • 打赏
  • 举报
回复
SQL SERVER2000 下,没问题啊!
zjcxc 元老 2003-08-09
  • 打赏
  • 举报
回复
错误应该不是出现在下面的语句上,我的电脑上也没有错.:
declare a_cur scroll cursor
for
select col1 from tb1
open a_cur
codeh 2003-08-09
  • 打赏
  • 举报
回复
怎么我电脑上试不会出现这种情况呢?我用的是SQL SERVER2000个人版
txlicenhe 2003-08-09
  • 打赏
  • 举报
回复
-- =============================================
-- Declare a SCROLL cursor and use various FETCH options
-- =============================================
DECLARE <cursor_name, sysname, test_cursor> SCROLL CURSOR FOR
<select_statement, , SELECT * FROM pubs.dbo.authors>

OPEN <cursor_name, sysname, test_cursor>

-- Fetch the first row in the cursor.
FETCH FIRST FROM <cursor_name, sysname, test_cursor>

-- Fetch the last row in the cursor.
FETCH LAST FROM <cursor_name, sysname, test_cursor>

-- Fetch the row immediately prior to the current row in the cursor.
FETCH PRIOR FROM <cursor_name, sysname, test_cursor>

-- Fetch the row immediately after the current row in the cursor.
FETCH NEXT FROM <cursor_name, sysname, test_cursor>

-- Fetch the nth row in the cursor.
FETCH ABSOLUTE <row_number, int, 8> FROM <cursor_name, sysname, test_cursor>

-- Fetch the row that is n rows before or after the current row.
FETCH RELATIVE <-/+ row_number, int, -2> FROM <cursor_name, sysname, test_cursor>

CLOSE <cursor_name, sysname, test_cursor>
DEALLOCATE <cursor_name, sysname, test_cursor>
GO

34,590

社区成员

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

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