Search Postgresql Archives

Re: PL/pgSQL: How to return two columns and multiple rows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 18, 2015 at 9:32 AM, Sven Geggus <lists@xxxxxxxxxxxxxxxxxxxxx> wrote:
David G. Johnston <david.g.johnston@xxxxxxxxx> 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.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux