'I Have an error in MySQL. Show me a syntaxt error in my query
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 1:[1]
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//
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | nbk |
