delimiter $$
DROP PROCEDURE IF EXISTS pro_test ;
CREATE PROCEDURE pro_test()
begin
DECLARE var_name varchar(50);
DECLARE fee_18 CURSOR FOR
select name from test;
DECLARE EXIT HANDLER FOR NOT FOUND CLOSE fee_18;
OPEN fee_18;
REPEAT
FETCH fee_18 into var_name;
insert into test2 select var_name;
UNTIL 0 END REPEAT;
CLOSE fee_18;
end;
$$
DELIMITER ;