I have this query in MySQL
create function is_prime(num int) returns boolean
begin
declare cont;
set cont = 2;
while(cont != num) do
if (num % cont = 0) then
return false;
end if;
cont = cont + 1;
end while;
return true;
end//
VSCode show a syntaxt error. I have checked each line but i dont look the error.
Thanks and sorry for my english.
>Solution :
Declaration has to have a datatype
Also you forgot to Set the increase
DELIMITER //
create function is_prime(num int) returns boolean
begin
declare cont INTEGER;
set cont = 2;
while(cont != num) do
if (num % cont = 0) then
return false;
end if;
SET cont := cont + 1;
end while;
return true;
end//