如何摆脱“错误1329:无数据-提取,选择或处理了零行",因此请参见“错误1329:无数据-提取,选择或处理了零行". [英] How to get rid of "Error 1329: No data - zero rows fetched, selected, or processed"
问题描述
我有一个存储过程,不需要返回任何值.它运行平稳,没有任何问题.但是,它在完成运行后会输出一条错误消息:
I have a stored procedure which does not need to return any values. It runs smoothly and without any problem. However, it outputs an error message after finishing its run:
错误:无数据-提取,选择或处理了零行
Error: No data - zero rows fetched, selected, or processed
如何摆脱此错误消息?
CREATE PROCEDURE `testing_proc`()
READS SQL DATA
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE l_name VARCHAR(20);
DECLARE my_cur CURSOR FOR
SELECT name FROM customer_tbl;
OPEN my_cur;
my_cur_loop:
LOOP FETCH my_cur INTO l_name;
IF done = 1 THEN
LEAVE my_cur_loop;
END IF;
INSERT INTO names_tbl VALUES(l_name);
END LOOP my_cur_loop;
CLOSE my_cur;
END
推荐答案
我想您只是忘了在帖子中添加以下行:
I guess you just forgot to include the following line in your post:
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
您的代码是正确的,但是mysql的错误/奇怪行为会导致即使出现警告,警告也会出现.您可以避免,如果在过程的末尾添加虚拟"语句以使表参与并且成功,则这将清除警告. (请参见 http://dev.mysql.com/doc/refman/5.5/en/show-warnings.html ) 就您而言:
Your code is correct, but bug/strange behaviour of mysql causes the warning to appear even if it was handled. You can avoid that if you add a "dummy" statement to the end of your procedure that invovles a table and is successful, this will clear the warning. (See http://dev.mysql.com/doc/refman/5.5/en/show-warnings.html) In your case:
SELECT name INTO l_name FROM customer_tbl LIMIT 1;
循环结束后的
. 在MySQL 5.5.13上,警告在Linux和Windows上消失. 我对MySQL Bug 60840进行了评论,希望他们能在将来的某个时间对其进行修复...
after the end of the loop. On MySQL 5.5.13 the warning disappears, on Linux and Windows. I commented on MySQL Bug 60840 and I hope they will fix it some time in the future...
这篇关于如何摆脱“错误1329:无数据-提取,选择或处理了零行",因此请参见“错误1329:无数据-提取,选择或处理了零行".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!