/*mysqll过程*/
CREATE PROCEDURE `NewProcedure`(`Param` int(11))
BEGIN
DECLARE b INT default 0;
declare var_id,var_value varchar(20) default null;
DECLARE cur1 cursor
FOR
select testId from test2 ;
declare continue handler for not found set b=1;
open cur1;
repeat
fetch cur1 into var_id;
/*本身repeat util是do while的形式,会多执行一次,加上if not b then判断解决多循环一次的问题*/
/*把do while形式的循环改成while*/
if not b then
select var_id;
set var_value = concat('testName:',var_id);
/*insert into test values(var_id,var_value);*/
end if;
until b=1
end repeat;
close cur1;
END;