From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Sven Geggus <lists(at)fuchsschwanzdomain(dot)de> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: PL/pgSQL: How to return two columns and multiple rows |
Date: | 2015-06-18 13:43:51 |
Message-ID: | CAKFQuwYpHh3vwJEV36wQRjR0yXnOikFmU0Ep=6TOfsUkMknZKg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Jun 18, 2015 at 9:32 AM, Sven Geggus <lists(at)fuchsschwanzdomain(dot)de>
wrote:
> David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Sven Geggus | 2015-06-18 13:47:31 | Re: PL/pgSQL: How to return two columns and multiple rows |
Previous Message | Sven Geggus | 2015-06-18 13:32:04 | Re: PL/pgSQL: How to return two columns and multiple rows |