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 Answers 2

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;
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.