Title: Procedure + Insert
Tags: mysql;mysql5;mysql-cluster
Question: I would like to create a procedure with a while but I have an error.
Here is my procedure:
Delimiter //
create procedure procedure1 ()
BEGIN
Declare i INT;
set i=1;
while i< 74 do
execute immediate 'insert into main values(3,"samples")'
set i=1+1;
end while;
end //
I got this error
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that on for   the right syntax to use near ''insert into main values(3,"samples")'
Someone has an idea please?


Here is another answer: Change your insert query in procedure like below
insert into main values(3,'samples')

Here is another answer: Use it like this :
- store your query into a variable
Delimiter //
create procedure procedure1 ()
BEGIN
Declare i INT;
v_Sql VARCHAR2(2000);
set i=1;
v_Sql :='insert into main values(3,"samples")';
while i< 74 do
EXECUTE IMMEDIATE v_Sql ;
set i=1+1;
end while;
end //

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2014:00:03/26/14', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<mysql><mysql5><mysql-cluster>', 'Title': 'Procedure + Insert', 'ViewCount': 54, 'id': 22673839, 'user_AboutMe': None, 'user_AccountId': None, 'user_DisplayName': None, 'user_Reputation': None, 'user_Views': None, 'user_id': None}}