Reputation: 111
I'm using xampp with phpMyAdmin to manage a MySql database. When creating a function I got a "No Return Found" error, so I stripped down the function to narrow the origin of the error I got to the simplest case where it still doesn't work.
And the error message is this:
Apparently if the RETURN
statement isn't the only thing on the code I get an error.
Upvotes: 0
Views: 508
Reputation: 16433
Assuming the actual code being executed against MySQL is:
CREATE FUNCTION `Contagem`() RETURNS INT(11)
SET @c = 0;
RETURN @c;
This will fail, because you have not wrapped the function in BEGIN
...END
.
Try instead to write this as your function declaration:
BEGIN
SET @c = 0;
RETURN @c;
END;
Alternatively, declare the function yourself directly in MySQL:
DELIMITER $$
CREATE FUNCTION `Contagem`() RETURNS INT(11)
BEGIN
SET @c = 0;
RETURN @c;
END $$
DELIMITER ;
Upvotes: 3
Reputation: 111
When reviewing this post I was reading more carefully the error message I realized the MySql code to define the function didn't have BEGIN
and END
in it.
I assumed when typing function code with several lines that phpMyAdmin would know how to handle it, since the code text box has support to multiple lines of code.
So, putting BEGIN
at the beginning and END
at the end of the code solved my problem.
Upvotes: 1