Reputation: 435
I'm trying to insert a bunch of records in my MySQL database table.
I am not expert to create a stored procedure.
Here is my code:
BEGIN
DECLARE var INT;
SET var = 0;
WHILE var < 100000 DO
INSERT INTO stored_copy (total, active, stored) VALUES (var, 1, 1);
SET var = var + 1;
END WHILE;
END;
Here is the error:
Can anyone check what I am doing wrong?
Upvotes: 0
Views: 964
Reputation: 51
Update the name of "stored" column in stored_copy table. stored is a reserved word.
Upvotes: 1
Reputation: 49373
stored is a reserved word you have to use backticks
see also When to use single quotes, double quotes, and backticks in MySQL
BEGIN
DECLARE var INT;
SET var = 0;
WHILE var < 100000 DO
INSERT INTO stored_copy (total, active, `stored`) VALUES (var, 1, 1);
SET var = var + 1;
END WHILE;
END;
Upvotes: 1