Re: create type with %type or %rowtype

From: Paul Förster <paul(dot)foerster(at)gmail(dot)com>
To: Post Gresql <postgresql(at)taljaren(dot)se>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: create type with %type or %rowtype
Date: 2020-11-19 06:04:43
Message-ID: 5EABB320-084A-42CD-8610-5BF6A37DE811@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

> On 18. Nov, 2020, at 22:08, Post Gresql <postgresql(at)taljaren(dot)se> wrote:
>
> I might be stupid, but where in the document for create function does it say that the return type can be a table?
>
> From the doc for version 13 https://www.postgresql.org/docs/13/sql-createfunction.html
>
> "rettype
> The return data type (optionally schema-qualified). The return type can be a base, composite, or domain type, or can reference the type of a table column."

right in the syntax:

CREATE [ OR REPLACE ] FUNCTION
name ( [ [ argmode ] [ argname ] argtype [ { DEFAULT | = } default_expr
] [, ...] ] )
[ RETURNS rettype
| RETURNS TABLE ( column_name column_type [, ...] ) ]

"RETURNS TABLE(...)" is probably what you're looking for?

Cheers,
Paul

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2020-11-19 06:11:00 Re: pg_upgrade from 12 to 13 failes with plpython2
Previous Message Bruce Momjian 2020-11-19 05:57:38 Re: pg_upgrade from 12 to 13 failes with plpython2