plpgsql returning resultset - Mailing list pgsql-general

From tfinneid@student.matnat.uio.no
Subject plpgsql returning resultset
Date
Msg-id 38087.134.32.140.234.1220350322.squirrel@webmail.uio.no
Whole thread Raw
Responses Re: plpgsql returning resultset
List 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


pgsql-general by date:

Previous
From: Edoardo Panfili
Date:
Subject: Re: immutable functions and enumerate type casts in indexes
Next
From: Martijn van Oosterhout
Date:
Subject: Re: immutable functions and enumerate type casts in indexes