本人写了一个mysql 存储过程,本人前面用DECLARE 定义了set _err为int类型默认为0,后面又用了下面方法
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION,SQLWARNING,NOT FOUND set _err=1;
本人在判断时候
if set_err =1 then
strReturn = “faliure”;
elseif
strReturn = “success”;
…
不管set_err的值为0还是别的,怎么都跳到 strReturn = “faliure”;呢?
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION,SQLWARNING,NOT FOUND set _err=1;
本人在判断时候
if set_err =1 then
strReturn = “faliure”;
elseif
strReturn = “success”;
…
不管set_err的值为0还是别的,怎么都跳到 strReturn = “faliure”;呢?
解决方案:20分
这是原因是你打开了游标,当游标的数据被全部取出就会报NOT FOUND,你的值就变为1了,当然不排除你还有错误就会报SQLEXCEPTION, SQLWARNING,值又为1.所以这句有问题导致的
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION, SQLWARNING, NOT FOUND SET v_t_error = 1;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION, SQLWARNING, NOT FOUND SET v_t_error = 1;