`
chenzhou123520
  • 浏览: 4259446 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

mysql procedure error:[Err] 1338 - Cursor declaration after handler declaration

阅读更多

今天编写了一个mysql存储过程定义语句,在执行的时候报错:

[Err] 1338 - Cursor declaration after handler declaration

经过排查后发现是我把游标的error handler定义在游标的定义语句之前,所以报错了,我的代码如下:

#define error handler
DECLARE CONTINUE handler for NOT FOUND set fetchMyCurOk = false; 
#define cursor
DECLARE myCur CURSOR for select box_seq,box_code,cupboard_name from ct_boxs_copy where inner_code=innercode;

解决方法很简单,就是把error handler的定义移到cursor的定义语句之后就可以了:

#define cursor
DECLARE myCur CURSOR for select box_seq,box_code,cupboard_name from ct_boxs_copy where inner_code=innercode;
#define error handler
DECLARE CONTINUE handler for NOT FOUND set fetchMyCurOk = false;

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics