为了账号安全,请及时绑定邮箱和手机立即绑定

关于游标的问题

关于游标的问题

芜湖不芜 2018-07-30 09:06:06
declare BRItemCusror cursor for select BRItemID from RechageItem where State=0 and AccountID=@AccountId;open BRItemCusrorfetch next from BRItemCusror into @BRItemID;为什么@@Fetch_Status = -1?  不明白出错在哪  明明定义游标的SQL查询结果是有记录的。
查看完整描述

2 回答

?
POPMUISE

TA贡献1765条经验 获得超5个赞

游标我的理解就是在SQL中循环,循环肯定是由条件的,修改成下面试试看:

declare BRItemCusror cursor for select BRItemID from RechageItem where State=0 and AccountID=@AccountId;open BRItemCusrorwhile    @@fetch_status=0  --结束的条件 
     begin   
         fetch next from BRItemCusror into @BRItemID;     endclose   BRItemCusror--关闭游标
 deallocate   BRItemCusror

另外看一下

select BRItemID from RechageItem where State=0 and AccountID=@AccountId;

这里面有东西吗?


查看完整回答
反对 回复 2018-08-01
?
达令说

TA贡献1821条经验 获得超6个赞

游标一般用一楼那个结构写的。

查看完整回答
反对 回复 2018-08-01
  • 2 回答
  • 0 关注
  • 705 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信