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;

猜你喜欢

转载自chenzhou123520.iteye.com/blog/1940076
今日推荐