RETURN QUERY in PL/PgSQL?

Поиск
Список
Период
Сортировка
От Neil Conway
Тема RETURN QUERY in PL/PgSQL?
Дата
Msg-id 1177363020.16415.156.camel@localhost.localdomain
обсуждение исходный текст
Ответы Re: RETURN QUERY in PL/PgSQL?  (Josh Berkus <josh@agliodbs.com>)
Re: RETURN QUERY in PL/PgSQL?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
In a PL/PgSQL set-returning function, returning the result set of a
query requires a FOR loop and repeated invocations of the RETURN NEXT
statement:
   FOR x in SELECT ... LOOP       RETURN NEXT x;   END LOOP;

This works, but it seems overly verbose. It occurred to me that we could
easily add a new PL/PgSQL statement that evaluates a set-returning
expression and adds *all* the resulting rows to the function's result
set. For example:
   RETURN QUERY SELECT ...;

I'm not sure of the right name: "RETURN ROWS" or "RETURN ALL" might also
work. Of course, this is syntax sugar (and superficial sugar at that),
but I believe this is a fairly common requirement.

Comments?

-Neil




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

Предыдущее
От: Gregory Stark
Дата:
Сообщение: Re: Better error message for select_common_type()
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: RETURN QUERY in PL/PgSQL?