警告1329没有提取数据

时间:2013-11-19 11:17:41

标签: mysql stored-procedures

delimiter ;;

create procedure cd3(out var int)
begin
   declare finished int default 0;
   declare cur cursor for select id from a;
   declare continue handler for not found set finished=1;
   open cur;
   curloop:loop
      fetch cur into var;
      if finished then
         leave curloop;
      end if;
   end loop curloop;
   close cur;
end;;

call cd3(@var);

1 个答案:

答案 0 :(得分:0)

这是MySQL提供的警告。它们可能有点令人困惑,我建议你阅读它:见http://dev.mysql.com/doc/refman/5./en/show-warnings.html

我会用这种方法代替

declare v_var VARCHAR(200); <-- if that whats it expected to be
open cur;

-- create a loop

repeat_cur: LOOP
FETCH cur INTO var;
-- checks if it is done
if finished then
    LEAVE repeat_cur;
end if;

// DO THE WORK

END LOOP;
close cur;

我不确定因为var是预期的out参数。您可以将var声明为变量并使用它,否则只需跳过我写的声明行。

查看此页面:How to get rid of "Error 1329: No data - zero rows fetched, selected, or processed",他遇到了同样的问题,并通过在var中添加一个简单的select语句来解决。

如果上述方法无效,请尝试在循环结束前添加此项。

SELECT 'var' INTO var;