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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: how to create a composite type as return type for a Function as Table Source
Дата
Msg-id 14630.1102905583@sss.pgh.pa.us
обсуждение исходный текст
Ответ на how to create a composite type as return type for a Function as Table Source  ("Tjibbe Rijpma" <t.b.rijpma@student.tudelft.nl>)
Список 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 по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: how to create a composite type as return type for a
Следующее
От: John DeSoi
Дата:
Сообщение: Re: basic download and setup questions