DROP PROCEDURE IF EXISTS mycursor;
CREATE PROCEDURE mycursor()
BEGIN
DECLARE v_done INT DEFAULT 0;
DECLARE v_a INT(6);
DECLARE v_b VARCHAR(20);
DECLARE cur_bak CURSOR FOR SELECT id, name FROM info;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET v_done = 1;
OPEN cur_bak;
REPEAT
FETCH cur_bak INTO v_a, v_b;
IF NOT v_done THEN
INSERT INTO infobak(id, name) VALUES (v_a, v_b);
END IF;
UNTIL v_done
END REPEAT;
CLOSE cur_bak;
END;
CALL mycursor;