MySql游标遍历的记录数不完整

在项目中使用MySql存储过程中,使用游标遍历数据,发现定义游标的查询语句有8条记录,循环遍历的时候却只循环了一次;
查看MySql官方文档才发现,不仅到达游标结尾会有NOT FOUND condition发生,select … into …,没有查到数据,同样也会有NOT FOUND condition发生,因此在遍历游标循环里使用select … into … 以后,一定要把循环标志位置位;MySql官方文档说明如下:
NOT FOUND: Shorthand for the class of SQLSTATE values that begin with ‘02’. This is relevant within the context of cursors and is used to control what happens when a cursor reaches the end of a data set. If no more rows are available, a No Data condition occurs with SQLSTATE value ‘02000’. To detect this condition, you can set up a handler for it or for a NOT FOUND condition.
The NOT FOUND condition also occurs for SELECT … INTO var_list statements that retrieve no rows.

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值