1、建立存储过程
create procedure pabin4()
BEGIN
declare status,id int;
declare az,ax varchar(100) default '';
declare mycur cursor for select * from abin5;
declare continue handler for not found set status=1;
open mycur;
set status=0;
loopLabel:LOOP
fetch mycur into id,az;
if status = 0 then
if az is not null then
set ax=CONCAT(az,'mycur');
else
set ax=CONCAT('mysql','mycur');
end if;
insert into abin5 values (id,ax);
end if;
if status = 1 then
leave loopLabel;
end if;
end loop;
close mycur;
END
2、测试语句
call pabin4()