delimiter // drop table if exists t1// create table t1(a int,unique(a),b varchar(30),key(b))engine=myisam// drop procedure if exists p1// create procedure p1(num int) begin declare count1 int default '0'; declare vb varchar(30); declare last_row int; while(num>=1) do set num=num+0; begin declare cur1 cursor for select a from t1; declare continue handler for not found set last_row = 1; set last_row:=0; open cur1; rep1: repeat begin declare exit handler for 1062 begin end; fetch cur1 into vb; if (last_row = 1) then leave rep1; end if; insert into t1 set a=1; end; until last_row=1 end repeat; close cur1; end; end while; end// delimiter ; call p1(100);