delimiter //
drop procedure if exists `test` //
CREATE PROCEDURE `test`() comment '测试存储过程'
BEGIN
declare a varchar(255);
declare i int(1) default 0;
DECLARE cur CURSOR FOR select tname from `test`;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION ,NOT FOUND
rollback;
start transaction;
OPEN cur;
while i<12 do
FETCH cur INTO a;
insert into `test` (tname) values (a);
set @ret=row_count();
if @ret<=0 then
rollback;
end if;
set i=i+1;
end while;
close cur;
commit;
end //
delimiter ;
call test();