All Forums Database
veskojl 12 posts Joined 04/12
19 Mar 2014
SELECT statement in FUNCTIONS

Hi Guys,
 
I need to create a function that reads its result from a table, so I need to use a SELECT statement to read the output. Something like that:

CREATE FUNCTION mydb.rate(a CHAR(3))
......
RETURN SELECT b FROM mytable WHERE x = a;

I'm not sure if this syntax is allowed. Couldn't find similar example in the docs.
Stored procedure is also an option, but the problem is I need to call it INLINE like that:

SELECT 100*sp_(a) FROM sometable;

and I'm not sure if this achievable.
 
Any idea or advice is welcome!
 
 

You must sign in to leave a comment.