Re: Returning multiple rows in 8.4

Поиск
Список
Период
Сортировка
От Raymond O'Donnell
Тема Re: Returning multiple rows in 8.4
Дата
Msg-id 4AF89B05.8010602@iol.ie
обсуждение исходный текст
Ответы Re: Returning multiple rows in 8.4  (Raymond O'Donnell <rod@iol.ie>)
Список pgsql-general
On 19:59,  wrote:
> how can I write a function to return multiple rows? ( in plpgsql )

Yep, it's all in the docs:

http://www.postgresql.org/docs/8.4/static/plpgsql-control-structures.html#PLPGSQL-STATEMENTS-RETURNING

> what is the return value of the function? records?

Depends on how you declare the function. There's an implicit type
declared for each table and view, so you can have your function return
SETOF users -

   create or replace function my_function(....)
   returns setof users
   as ... (etc)

- and then the returned set will be rows of the users table.

Alternatively, you could declare a custom type and return a SETOF that
instead.

Finally, you can use OUT parameters to return multiple values from the
function - this is handy if you need to return just a few values.


Ray.


--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

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

Предыдущее
От: Gordon Callan
Дата:
Сообщение: Tsearch2 with Japanese
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: What to install to be able to build docs on Arch Linux?