Wednesday, 21 August 2013

PostgreSQL: Serially apply table-valued function to a set of values and UNION ALL results

PostgreSQL: Serially apply table-valued function to a set of values and
UNION ALL results

I have a table-valued PL/pgsql function that takes as 1 input an integer,
an ID. The table that is returned has fixed columns (say 5) but varying
number of rows.
There is a large table of these unique IDs. I'd like to apply this
function to each ID and UNION ALL the results.
Looking online I keep seeing CROSS APPLY as the solution, but it does not
appear to be available in PostgreSQL. How can I do this "apply" operation?
One trivial solution is to re-write the table-valued function with an
additional outer loop. But is there a way to do this directly in SQL?

No comments:

Post a Comment