Re: plpgsql returning resultset

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: tfinneid(at)student(dot)matnat(dot)uio(dot)no
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: plpgsql returning resultset
Date: 2008-09-02 10:32:25
Message-ID: 48BD1639.7050401@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 02/09/2008 11:12, tfinneid(at)student(dot)matnat(dot)uio(dot)no wrote:

> create function test2() returns setof record as
> $$
> declare
> val_list record;
> begin
> select * into val_list from tableA;
> return next val_list;
> return:
> end
> $$ .....

Hi there,

You need to do it like this:

with val_list in
select * from tableA do
loop
return next val_list;
end loop;
return;

There's an example here:

http://www.postgresql.org/docs/8.3/static/plpgsql-control-structures.html#PLPGSQL-STATEMENTS-RETURNING

Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod(at)iol(dot)ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message jose lawrence 2008-09-02 11:16:06 Conflict between MVCC and manual locking
Previous Message Martijn van Oosterhout 2008-09-02 10:28:43 Re: immutable functions and enumerate type casts in indexes