DELIMITER $$
DROP PROCEDURE IF EXISTS sp_test1$$
CREATE PROCEDURE sp_test1()
BEGIN
DECLARE i INT;
DECLARE size INT DEFAULT 0;
DECLARE str VARCHAR(3) DEFAULT '';
DECLARE num VARCHAR(4) DEFAULT '';
SET i=0;
SET autocommit=0;
WHILE i<10000 DO
SET size = LENGTH(''+i);
IF size=1 THEN
SET str = '000';
ELSEIF size=2 THEN
SET str='00';
ELSEIF size=3 THEN
SET str='0';
ELSE
SET str='';
END IF;
SET num=CONCAT(str,i);
INSERT INTO temp(number) VALUES(num);
SET i=i+1;
DELIMITER ;
DROP PROCEDURE IF EXISTS sp_test1$$
CREATE PROCEDURE sp_test1()
BEGIN
DECLARE i INT;
DECLARE size INT DEFAULT 0;
DECLARE str VARCHAR(3) DEFAULT '';
DECLARE num VARCHAR(4) DEFAULT '';
SET i=0;
SET autocommit=0;
WHILE i<10000 DO
SET size = LENGTH(''+i);
IF size=1 THEN
SET str = '000';
ELSEIF size=2 THEN
SET str='00';
ELSEIF size=3 THEN
SET str='0';
ELSE
SET str='';
END IF;
SET num=CONCAT(str,i);
INSERT INTO temp(number) VALUES(num);
SET i=i+1;
END WHILE;
COMMIT;
DELIMITER ;