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

Поиск
Список
Период
Сортировка
От Tjibbe Rijpma
Тема how to create a composite type as return type for a Function as Table Source
Дата
Msg-id 00a001c4ddf8$ce229fa0$1a0313ac@TJIBBE
обсуждение исходный текст
Ответы Re: how to create a composite type as return type for a  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Re: how to create a composite type as return type for a Function as Table Source  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
Hello,

I want to make a Function as table source. As rettype you have to give a
composite type but how do I make those? I'm using an new empty table with
the the datatypes (INT, INT8, TEXT and a TIMESTAMP) I need.

Is this the normal way how to make composite types?

Example:

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


CREATE OR REPLACE FUNCTION get_reservations (int) RETURNS SETOF
bigint_int_text AS $$

SELECT     r.id,
                   p.id,
                   description,
                   last_time
FROM       reservations r,
                  persons p
WHERE    product_id =  $1

$$ LANGUAGE SQL;


В списке pgsql-novice по дате отправления:

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