如何看游标里有什么记录

reanna 2003-06-24 06:05:01
--声明游标变量
DECLARE
@priority int,
@vendor_id varchar(10)

DECLARE vendor_cursor CURSOR FOR
SELECT vendor_id,priority FROM wh_vendor_pay_info WHERE trans=1 AND priority=0
OPEN vendor_cursor
FETCH FROM vendor_cursor
INTO @vendor_id,@priority
WHILE @@FETCH_STATUS=0
BEGIN
UPDATE wh_vendor_pay_info SET priority=0 WHERE (trans=0) AND (vendor_id<>@vendor_id)

FETCH vendor_cursor
INTO @vendor_id,@priority
END

--关闭游标
CLOSE vendor_cursor
--释放游标
DEALLOCATE vendor_cursor

----------------

SELECT vendor_id,priority FROM wh_vendor_pay_info WHERE trans=1 AND priority=0
OPEN vendor_cursor
FETCH FROM vendor_cursor
INTO @vendor_id,@priority

如何看看此时游标中@vendor_id,@priority是什么值?



















FETCH vendor_cursor
INTO @vendor_id,@priority
END

--关闭游标
CLOSE vendor_cursor
--释放游标
DEALLOCATE vendor_cursor
...全文
45 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xah_JD 2003-06-25
  • 打赏
  • 举报
回复
print @vendor_id
print @priority
hjb111 2003-06-24
  • 打赏
  • 举报
回复
SELECT vendor_id,priority FROM wh_vendor_pay_info WHERE trans=1 AND priority=0
OPEN vendor_cursor
FETCH FROM vendor_cursor
INTO @vendor_id,@priority

--如何看看此时游标中@vendor_id,@priority是什么值?
while @@fetch_status=0
begin
print @vendor_id
print @priority
end
FETCH vendor_cursor
INTO @vendor_id,@priority
END

--关闭游标
CLOSE vendor_cursor
--释放游标
DEALLOCATE vendor_cursor
pengdali 2003-06-24
  • 打赏
  • 举报
回复
如:

declare cursor_insert cursor for select c# from cs
declare @i int
open cursor_insert
fetch cursor_insert into @i
while @@fetch_status=0
begin
print @i
fetch cursor_insert into @i
end
close cursor_insert
deallocate cursor_insert
愉快的登山者 2003-06-24
  • 打赏
  • 举报
回复
select @vendor_id,@priority
CrazyFor 2003-06-24
  • 打赏
  • 举报
回复
SELECT vendor_id,priority FROM wh_vendor_pay_info WHERE trans=1 AND priority=0
OPEN vendor_cursor
FETCH FROM vendor_cursor
INTO @vendor_id,@priority

--如何看看此时游标中@vendor_id,@priority是什么值?
  print 'Vendor:'+ cast(@vendor_id as varchar)
print 'Priority:'+cast(@priority as varchar(1000)



FETCH vendor_cursor
INTO @vendor_id,@priority
END

--关闭游标
CLOSE vendor_cursor
--释放游标
DEALLOCATE vendor_cursor

34,872

社区成员

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

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