I have a stored procedure which returns several values (1 row). I need to use the results of that stored procedure in a select query.
Here is pseudo-code of how I would like it to be (such syntax does not exist, but let's pretend it would allow to save 3 values, which my stored procedure returns, into C, D and E):
SELECT
t1.A, t1.B,
MyStoredProc(t1.A) AS (C, D, E)
FROM
t1
ORDER BY
D
LIMIT
1
(on the client side I need to get A, B, C, D and E)
I can rewrite the stored procedure to a stored function which returns values as a concatenated string with delimiters and parse out the values in the query, but I would like to find a cleaner solution.
SELECT t1.A, t1.B, myStoredFunc(t1.A, 1) AS C, myStoredFunc(t1.A, 2) AS D, myStoredFunc(t1.A, 3) AS E FROM t1 ORDER BY D LIMIT 1