I must find the sum of the first 100 natural numbers. 1+2+3+…+n, and so on. While using "while loops".
delimiter $
create procedure `calcul`.somme()
begin
declare s int default 0;
declare i int default 1;
while(i<=100) do
set s := s+i;
set i := i+1;
end while;
select s;
end;
$
call `calcul`.somme()
when I call the somme() I’m getting this error –>
call calcul.somme()= Error Code: 2013. Lost connection to MySQL server during query
2
Answers
thanks, the Problem solved 👌
The query is taking too long and the engine is timing out.
You can edit the SQL Editor preferences in MySQL Workbench: