0

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:

enter image description here

Can anyone check what I am doing wrong?

2 Answers2

1

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;
nbk
  • 31,930
  • 6
  • 24
  • 40
1

Update the name of "stored" column in stored_copy table. stored is a reserved word.

Chris
  • 51
  • 1
  • 9