Re: set-returning function in pg 7.4.6

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: set-returning function in pg 7.4.6
Дата
Msg-id 20050314075335.K8517@megazone.bigpanda.com
обсуждение исходный текст
Ответ на set-returning function in pg 7.4.6  (Raphael Bauduin <raphael.bauduin@be.easynet.net>)
Список pgsql-novice
On Mon, 14 Mar 2005, Raphael Bauduin wrote:

> Here's the function:
>
> create or replace function GetRows() returns setof int as
> '
> declare
>     r record;
> begin
>     for r in EXECUTE ''select customer_id from customers'' loop
>         return next r.customer_id;
>     end loop;
>     return;
> end
> '
> language 'plpgsql';
>
>
> When I call this function as
>
>  select GetRows();
>
> I get this error:
>
> ERROR:  set-valued function called in context that cannot accept a set
> CONTEXT:  PL/pgSQL function "getrows" line 5 at return next

You need to call it with the function in the from clause
 select * from GetRows();

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

Предыдущее
От: Raphael Bauduin
Дата:
Сообщение: set-returning function in pg 7.4.6
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: set-returning function in pg 7.4.6