I'm trying to write a procedure in MySQL to execute 30 (or more) inserts into a table. The table has other fields such ID
etc, but ID
is an auto_increment
field and the others are not important.
This is where I got so far looking at other StackOverflow questions:
DROP PROCEDURE IF EXISTS test;
DELIMITER #
CREATE PROCEDURE test()
BEGIN
DECLARE i INT UNSIGNED DEFAULT 1;
WHILE i < 30
INSERT INTO account (login, password)
SELECT concat('test', i), '*00A51F3F48415C7D4E8908980D443C29C69B60C9';
SET i = i + 1;
END WHILE;
COMMIT;
END #
DELIMITER;
CALL test();
But MySQL returns the error 1064 "Syntax error on line 7, check your manual". Line 7 is the one that begins with WHILE
.
I also tried with this INSERT
statement:
INSERT INTO account (login, password)
VALUES (concat('test', i), '*00A51F3F48415C7D4E8908980D443C29C69B60C9');
But without any luck, MySQL gives back the same error.
Is there something I'm missing? Or this is something that just can't be accomplished?
Thanks in advance.