Re: set-returning function in pg 7.4.6 - Mailing list pgsql-novice

From Stephan Szabo
Subject Re: set-returning function in pg 7.4.6
Date
Msg-id 20050314075335.K8517@megazone.bigpanda.com
Whole thread Raw
In response to set-returning function in pg 7.4.6  (Raphael Bauduin <raphael.bauduin@be.easynet.net>)
List 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 by date:

Previous
From: Raphael Bauduin
Date:
Subject: set-returning function in pg 7.4.6
Next
From: Michael Fuhr
Date:
Subject: Re: set-returning function in pg 7.4.6