Table returning functions

Поиск
Список
Период
Сортировка
От Jann Röder
Тема Table returning functions
Дата
Msg-id i683es$v8b$1@dough.gmane.org
обсуждение исходный текст
Ответы Re: Table returning functions
Список pgsql-sql
Hi,
I have a question which does not seem to be covered in the
documentation: I have a function f(i) that returns a table with three
columns (a, b, c).

In the documentation
(http://www.postgresql.org/docs/8.4/interactive/xfunc-sql.html#XFUNC-SQL-FUNCTIONS-RETURNING-SET)
it says that (even though deprecated) you can call such functions in a
SELECT clause like so:

SELECT id, f(id) FROM some_table .

This will give me a two column table that looks like this:

id | (a, b, c)

However since I want a 4 column table like this
id | a | b | c

, I do this instead:

SELECT id, (f(id)).a, (f(id)).b, (f(id)).c FROM some_table.

However I'm not quite sure if this really gives me what I want (i.e. the
same as in the first query only with the tuple elements as separate
columns).

Of course I'm open to suggestions on how to do this more elegantly and
also how one can do something like this without using the deprecated
feature of calling a set returning function in SELECT.

Jann



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

Предыдущее
От: Lew
Дата:
Сообщение: Re: is there a distinct function for comma lists ?
Следующее
От: Tim Schumacher
Дата:
Сообщение: Re: Generating Rows from a date and a duration