Re: how to create a composite type as return type for a Function as Table Source - Mailing list pgsql-novice

From Tom Lane
Subject Re: how to create a composite type as return type for a Function as Table Source
Date
Msg-id 14630.1102905583@sss.pgh.pa.us
Whole thread Raw
In response to how to create a composite type as return type for a Function as Table Source  ("Tjibbe Rijpma" <t.b.rijpma@student.tudelft.nl>)
List pgsql-novice
"Tjibbe Rijpma" <t.b.rijpma@student.tudelft.nl> writes:
> I want to make a Function as table source. As rettype you have to give a
> composite type but how do I make those?

Best way is

CREATE TYPE typename AS (colname coltype, colname coltype, ...);

> Is this the normal way how to make composite types?

> CREATE TABLE bigint_int_text_timestamp (
>     column_1 INT8,
>     column_2 INT,
>     column_3 TEXT,
>     column_4 TIMESTAMP);

You can do that too, since a table declaration creates an associated
rowtype.  But if you only intend to use the rowtype and not the actual
table, I think it's more understandable to declare the type as a type.

            regards, tom lane

pgsql-novice by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: how to create a composite type as return type for a
Next
From: John DeSoi
Date:
Subject: Re: basic download and setup questions