On Thu, Jun 18, 2015 at 9:32 AM, Sven Geggus <li...@fuchsschwanzdomain.de>
wrote:

> David G. Johnston <david.g.johns...@gmail.com> wrote:
>
> > Look at the "returns table (col1 type, col2 type)" form.
>
> If I got this right "returns table" is not what I want as I need to select
> from my function as a virtual table in this case.
>

​Yes, I mis-read your question.  Your issue is placing the SRF (set
returning function) in the select-list which causes it to be treated as a
single composite-typed column.  You need to place the function in after
"FROM" or "LATERAL"

Something like:

SELECT * FROM src_tbl LATERAL my_func(src_tbl.col1, src_tbl.col2)​

I haven't had much experience writing lateral clauses but their benefit is
that they can reference columns from other tables so you don't have to
place the function in the select-list.

David J.

Reply via email to