Reputation: 4702
I have a problem making a stored mysql function. First I tried to make it quite easy following the official tutorial: http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html
create function bestalldavaror_7()
RETURNS int DETERMINISTIC
RETURN select sum(mangd) from bestalln where artikel_id = 7;
The select-query works just fine by itself and the "mangd" is an int(11) value (so is everything in that table). So why does this generate an error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select sum(mangd) from bestalln where artikel_id = 7' at line 3
Upvotes: 0
Views: 791
Reputation: 31406
So make this change:
create function bestalldavaror_7()
RETURNS int DETERMINISTIC
RETURN (select sum(mangd) from bestalln where artikel_id = 7);
and it should work.
Upvotes: 1