我试图在游标的循环中调用 MySQL 中的存储过程。在循环中执行 INSERT 时光标行为正常;但是如果我尝试调用存储过程,则 continue Handler '设置完成 = 1' 并在处理第一条记录后过早退出循环。关于如何解决这个问题的任何想法?谢谢。
declare test_cursor cursor for
select projectid, projectdesc
from tblProjects
order by projectdesc;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
set done = 0;
open test_cursor;
repeat
fetch test_cursor into wprojectid, wprojectdesc;
if not done then
insert into tblTest (a, b) values (wprojectid, wprojectdesc); <--this would work
call spTest(wprojectid, wprojectdesc, @retrn); <--this trips the Handler after first loop
end if;
until done end repeat;
close test_cursor;