Link to home
Start Free TrialLog in
Avatar of mwskuzzy
mwskuzzy

asked on

While Loops In MySQL

I am am MS SQL developer and I am busy trying to migrate over to MySQL. I need to populate a table for testing and I would like to do this using a while loop. I noticed that MySQL does support the while conditional statement but for some reason it does not want to work. I noticed that is I wrap it in a stored procedure then it works fine????

Please tell me if I can run a while loop directly or are all conditional statements limited to stored procedures and functions?

Set @i = 0;
while @i < 1000000 do
Insert into payment_instructions (acc_no,acc_type,br_code,br_name,bank_name,instr_val,dt_date)
Values ('4252123521','Current','632005','Witbank','ABSA',138.52,01);
Set @i = @i+1;
end while;
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial