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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: PL/pgSQL: How to return two columns and multiple rows
Дата
Msg-id 3271.1434632581@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: PL/pgSQL: How to return two columns and multiple rows  (Raymond O'Donnell <rod@iol.ie>)
Список 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 по дате отправления:

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: PL/pgSQL: How to return two columns and multiple rows
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: PL/pgSQL: How to return two columns and multiple rows