Re: how to create a composite type as return type for a Function as Table Source

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Tjibbe Rijpma" <t(dot)b(dot)rijpma(at)student(dot)tudelft(dot)nl>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: how to create a composite type as return type for a Function as Table Source
Date: 2004-12-13 02:39:43
Message-ID: 14630.1102905583@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Tjibbe Rijpma" <t(dot)b(dot)rijpma(at)student(dot)tudelft(dot)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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tjibbe Rijpma 2004-12-13 09:18:02 How to creata a recursive function for tree with loops in it
Previous Message Stephan Szabo 2004-12-13 02:09:13 Re: how to create a composite type as return type for a