On Wed, Dec 22, 2010 at 11:38 AM, Kelly Burkhart
<kelly.burkhart@gmail.com> wrote:
> On Wed, Dec 22, 2010 at 10:19 AM, Merlin Moncure <mmoncure@gmail.com> wrote:
>> have you ruled out sending all the data you need to send into say, a
>> plpgsal function and doing the work there?
>>
>
> Not sure that would do what they need, which is get a list of users,
> get a list of accounts, get perhaps several other lists of other
> things to populate gui elements (mostly small queries). To do this
> within a stored procedure, the procedure would either have to return
> multiple PGresult objects with different columns (is that possible?)
> or we'd have to shoehorn everything into one result set with some kind
> of indicator on each row to indicate what kind of row it is. The
> second option is (to me anyway) clearly inferior to just sending a
> list of queries then reaping their PGresults as they come in.
it is completely possible.
create type account_t as row(id int, name text);
create or replace function app_login(
accounts out account_t[]
users out user_t[]) returns record as
$$
begin
select array(select id, name from account into accounts);
...
end;
$$ language plpgsql;
arrays come back over libpq as text, unless you use libpqtypes (which
i co-wrote) :-).
http://libpqtypes.esilo.com/man3/pqt-composites.html
merlin