Re: set-returning function in pg 7.4.6

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Raphael Bauduin <raphael(dot)bauduin(at)be(dot)easynet(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: set-returning function in pg 7.4.6
Date: 2005-03-14 15:55:51
Message-ID: 20050314075335.K8517@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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();

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Fuhr 2005-03-14 16:06:52 Re: set-returning function in pg 7.4.6
Previous Message Raphael Bauduin 2005-03-14 15:50:38 set-returning function in pg 7.4.6