Search Postgresql Archives

Re: Functions returning multiple rowsets

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

 



2009/9/28 Merlin Moncure <mmoncure@xxxxxxxxx>


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.

[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