From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Ron <ronljohnsonjr(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Ad hoc SETOF type definition? |
Date: | 2023-09-26 18:09:52 |
Message-ID: | e7b3900c-dfec-4058-d7d0-0e0ce2749172@aklaver.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 9/26/23 11:03 AM, Ron wrote:
> On 9/26/23 12:46, Tom Lane wrote:
>> Ron<ronljohnsonjr(at)gmail(dot)com> writes:
>>> Is there a way to define the SETOF record on the fly, like you do with
>>> RETURNS TABLE (f1 type1, f2 type2)?
>> Doesn't RETURNS TABLE meet the need already?
>
> That rationale means that RETURN SETOF is not needed, and can be
> removed from Pg, since "RETURNS TABLE meet the need already".
>
> But of course there /are/ times when RETURN SETOF /is/ useful.
>
> So... can ad hoc SETOF definitions be created in the function
> definition, or is CREATE TYPE the only way to do it?
That is what RETURNS TABLE does:
https://www.postgresql.org/docs/current/sql-createfunction.html
"/|column_name|/
The name of an output column in the |RETURNS TABLE| syntax. This is
effectively another way of declaring a named |OUT| parameter, except
that |RETURNS TABLE| also implies |RETURNS SETOF|.
"
>
> --
> Born in Arizona, moved to Babylonia.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2023-09-26 18:15:03 | Re: Ad hoc SETOF type definition? |
Previous Message | Ron | 2023-09-26 18:03:34 | Re: Ad hoc SETOF type definition? |