plpgsql returning resultset

From: tfinneid(at)student(dot)matnat(dot)uio(dot)no
To: pgsql-general(at)postgresql(dot)org
Subject: plpgsql returning resultset
Date: 2008-09-02 10:12:02
Message-ID: 38087.134.32.140.234.1220350322.squirrel@webmail.uio.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

I know the subject has been discussed before, but I dont find what any
information that helps me make it work, so please bear with me.

In pg 8.2 I want to write a function that gathers data from different
tables and joins it into a single resultset, similar to "select * from
tableA", but the problem I keep having is that I cant get the return to
work. I have tried return next and it fails. I have also tried refcursor,
but am not sure if that is the best way, its a littlebit cumbersome in a
program.

Are those the only two options? and what did I do wrong in the return next

create function test2() returns setof record as
$$
declare
val_list record;
begin

select * into val_list from tableA;
return next val_list;
return:
end
$$ .....

with the query:
select test2();

ERROR: set-valued function called in context that cannot accept a set
CONTEXT: line 9 at return next

regards thomas

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2008-09-02 10:28:43 Re: immutable functions and enumerate type casts in indexes
Previous Message Edoardo Panfili 2008-09-02 08:53:03 Re: immutable functions and enumerate type casts in indexes