Re: Return unknown resultset from a function

Поиск
Список
Период
Сортировка
От Rory Campbell-Lange
Тема Re: Return unknown resultset from a function
Дата
Msg-id 20120304204315.GA11159@campbell-lange.net
обсуждение исходный текст
Ответ на Return unknown resultset from a function  (Jan Meyland Andersen <jma@agile.dk>)
Ответы Re: Return unknown resultset from a function  (Rory Campbell-Lange <rory@campbell-lange.net>)
Список pgsql-general
On 04/03/12, Jan Meyland Andersen (jma@agile.dk) wrote:
> How do I return an unknown resultset from a function
>
> My main problem is that I do not know how many columns or the data
> type of the columns before runtime.
> It this possible at all?
>
> I also tried to return the data as a text array but I also have
> trouble with that.

There is a section on this in the docs at (for instance)
http://www.postgresql.org/docs/8.4/static/xfunc-sql.html#XFUNC-OUTPUT-PARAMETERS

A specific example which may help is

CREATE FUNCTION new_emp() RETURNS emp AS $$
    SELECT ROW('None', 1000.0, 25, '(2,2)')::emp;
$$ LANGUAGE SQL;

Note that there are two ways of calling such a function. You probably
want the "SELECT *" form.

Rory

--
Rory Campbell-Lange
rory@campbell-lange.net

Campbell-Lange Workshop
www.campbell-lange.net
0207 6311 555
3 Tottenham Street London W1T 2AF
Registered in England No. 04551928

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: || versus concat( ), diff behavior
Следующее
От: Rory Campbell-Lange
Дата:
Сообщение: Re: Return unknown resultset from a function