From: | Thom Brown <thombrown(at)gmail(dot)com> |
---|---|
To: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Functions returning multiple rowsets |
Date: | 2009-09-29 12:48:53 |
Message-ID: | bddc86150909290548h3eb06c31k92ec609ea896f68d@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2009/9/28 Merlin Moncure <mmoncure(at)gmail(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Sam Mason | 2009-09-29 12:54:58 | Re: query is taking longer time after a while |
Previous Message | Raymond O'Donnell | 2009-09-29 12:48:03 | Re: Delphi connection ? |