1329无数据 - 提取,选择或处理零行 [英] 1329 No data - zero rows fetched, selected, or processed
问题描述
大家好
这是我的存储过程
Hi all
This is my stored procedure
delimiter //
CREATE PROCEDURE cursorproc()
BEGIN
DECLARE n int;
DECLARE _continue INT DEFAULT 0;
DECLARE cur_1 CURSOR FOR SELECT n1 FROM num;
DECLARE exit HANDLER FOR NOT FOUND
SET _continue =1;
OPEN cur_1;
REPEAT
FETCH cur_1 INTO n;
insert into t1 values(n);
UNTIL _continue = 1
END REPEAT;
CLOSE cur_1;
END
//
$ b已将$ b值插入表中,但收到如下警告
1329无数据 - 提取,选择或处理零行。
我来解决这个问题。在此先感谢
values got inserted into the table but getting warning as follows
1329 No data - zero rows fetched, selected, or processed.
Hepl me to solve this. Thanks in advance
推荐答案
我想您只是忘了在帖子中包含以下内容:
I guess you just forgot to include the following line in your post:
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
您的代码是正确的,但mysql的错误/奇怪行为会导致警告出现,即使它已被处理。如果在程序结束时添加虚拟语句来调用表并且成功,则可以避免这种情况,这将清除警告。 (请参阅警告的方式)在您的情况下:
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 how warnings) 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...
delimiter //
CREATE PROCEDURE cursorproc()
BEGIN
DECLARE n int;
DECLARE _continue INT DEFAULT 0;
DECLARE cur_1 CURSOR FOR SELECT n1 FROM num;
DECLARE continue HANDLER FOR NOT FOUND
SET _continue =1;
OPEN cur_1;
l1:loop
FETCH cur_1 INTO n;
if _continue!=1 then
insert into t1 values(n);
else
leave l1;
end if;
END loop;
close cur_1;
END
//
这篇关于1329无数据 - 提取,选择或处理零行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!