set-returning function in pg 7.4.6

From: Raphael Bauduin <raphael(dot)bauduin(at)be(dot)easynet(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: set-returning function in pg 7.4.6
Date: 2005-03-14 15:50:38
Message-ID: 4235B2CE.9050508@be.easynet.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,

I need to write a function returning a set of integer.
I'm basing this example on GetRows from http://techdocs.postgresql.org/guides/SetReturningFunctions

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

What am I doing wrong?

Raph

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Stephan Szabo 2005-03-14 15:55:51 Re: set-returning function in pg 7.4.6
Previous Message David Gagnon 2005-03-14 14:13:27 Re: preoblem in jdbc postgresql and tomcat