Re: PL/pgSQL: How to return two columns and multiple rows - Mailing list pgsql-general

From Tom Lane
Subject Re: PL/pgSQL: How to return two columns and multiple rows
Date
Msg-id 3271.1434632581@sss.pgh.pa.us
Whole thread Raw
In response to Re: PL/pgSQL: How to return two columns and multiple rows  (Raymond O'Donnell <rod@iol.ie>)
List pgsql-general
"Raymond O'Donnell" <rod@iol.ie> writes:
> On 18/06/2015 13:36, Sven Geggus wrote:
>> I would like to be able to do something like this:
>>
>> select myfunc('foo','bar');
>> or
>> select myfunc(foo, bar) from foobartable;
>> or even
>> select myfunc(foo, bar), 'baz' as baz from foobartable;

> You need to do:

>    select * from myfunc('foo','bar');

That's enough to expand the output from a simple function call.  If you
want to do something like Sven's later examples, the best way is with
LATERAL:

select f.*, 'baz' as baz from foobartable, lateral myfunc(foo, bar) as f;

            regards, tom lane


pgsql-general by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: PL/pgSQL: How to return two columns and multiple rows
Next
From: "David G. Johnston"
Date:
Subject: Re: PL/pgSQL: How to return two columns and multiple rows