Re: Functions returning multiple rowsets

Поиск
Список
Период
Сортировка
От Thom Brown
Тема Re: Functions returning multiple rowsets
Дата
Msg-id bddc86150909290548h3eb06c31k92ec609ea896f68d@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Functions returning multiple rowsets  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-general
2009/9/28 Merlin Moncure <mmoncure@gmail.com>


with s as (select * from two_sets()),
foo as (select unnest(_foos) from s),
bar as (select unnest(_bars) from s)
select
 (select count(*) from foo) as no_foos,
 (select count(*) from bar) as no_bars;

merlin

I can see this working as we will be using 8.4.1, although it does seem rather unintuitive and clumsy.  I can see there's no straightforward way of achieving multiple result sets in the output.  I would have hoped for something like "returns record[]" to denote an array of records or "returns setof table" where table would be a parent database object of every other table.  I can work around this problem though, but I imagine it is something many people coming from MSSQL might be looking for.

As for seeking 2 result sets from code without any clever processing, you can just write as many queries as you want in PHP, and the results come out separate result sets in the result array. (e.g. $results[0] = first query, $results[1] = second query etc)

Thanks for the explanation Merlin.

В списке pgsql-general по дате отправления:

Предыдущее
От: Raymond O'Donnell
Дата:
Сообщение: Re: Delphi connection ?
Следующее
От: Sam Mason
Дата:
Сообщение: Re: query is taking longer time after a while