Function to return both integer and SETOF refcursor

From: Chuck Bai <cbai22(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Function to return both integer and SETOF refcursor
Date: 2008-05-17 02:50:20
Message-ID: 482E47EC.5010305@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I got the following error when try to create a function to return an
integer and SETOF refcursor. I want to get refcursors back along with an
Out parameter in one function. There seems to be a conflict on return
type. How do I fix it? Thanks.

ERROR: function result type must be integer because of OUT parameters

CREATE OR REPLACE FUNCTION testrefcursor(IN uid integer, OUT tcount integer)
RETURNS SETOF refcursor AS
$BODY$
DECLARE
o_user refcursor;
o_name refcursor;
BEGIN
tcount := 100; -- add some logic to calculate tcount
OPEN o_user FOR SELECT * FROM usr_table where usr_id = uid;
RETURN NEXT o_user;
OPEN o_name FOR SELECT * FROM temp_table;
RETURN NEXT o_name;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-05-17 02:50:45 Re: Using role priviledges for pg_dump
Previous Message PJ 2008-05-17 01:23:29 migration problem