From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Rob Sargent <robjsargent(at)gmail(dot)com> |
Cc: | Guyren Howe <guyren(at)gmail(dot)com>, stan <stanb(at)panix(dot)com>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Returning a table from a function, that requires multiple selects? |
Date: | 2019-08-30 20:34:27 |
Message-ID: | 9270.1567197267@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Rob Sargent <robjsargent(at)gmail(dot)com> writes:
>> On Aug 30, 2019, at 2:09 PM, Guyren Howe <guyren(at)gmail(dot)com> wrote:
>>
>> On Aug 30, 2019, at 13:03 , stan <stanb(at)panix(dot)com <mailto:stanb(at)panix(dot)com>> wrote:
>>> Is it possible for a function to return a table with results from multiple
>>> queries?
>> You could just return a tuple VALUES(a, b). Or you could define a type to return if you want to get fancy.
> Here I you might want VALUE(array[‘heading1’,a], array[‘heading2',b]) unless you’re certain you know which date is which.
Yeah, that would be a good reason to return a declared composite type.
Something like
CREATE TYPE two_dates AS (start date, stop date);
CREATE FUNCTION f(...) RETURNS two_dates AS ...;
SELECT * FROM f(...);
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | stan | 2019-08-30 22:12:25 | Re: Returning a table from a function, that requires multiple selects? |
Previous Message | Rob Sargent | 2019-08-30 20:23:32 | Re: Returning a table from a function, that requires multiple selects? |