Returning just one resultset from function call with refcursor return

From: "Francisco Figueiredo Jr(dot)" <fxjrlists(at)yahoo(dot)com(dot)br>
To: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Returning just one resultset from function call with refcursor return
Date: 2004-09-20 22:59:14
Message-ID: 414F60C2.7030506@yahoo.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi guys,

I'd like to know how you are doing to return a cursor resultset from
function call.

I know, from documentation, that I can do the following:

CREATE TABLE test (col text);
INSERT INTO test VALUES ('123');

CREATE FUNCTION reffunc(refcursor) RETURNS refcursor AS '
BEGIN
OPEN $1 FOR SELECT col FROM test;
RETURN $1;
END;
' LANGUAGE plpgsql;

BEGIN;
SELECT reffunc('funccursor');
FETCH ALL IN funccursor;
COMMIT;

The problem is that when I execute the lines above I get:

reffunc
------------
funccursor
(1 row)
col
-----
123
(1 row)

I'd like to omit the reffunc resultset return and get directly the col
resultset. Is this possible?

Thanks in advance.

Please, let me know if this is not the appropriated place to do such
questions.

Regards,

Francisco Figueiredo Jr.

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2004-09-20 23:11:17 Re: Returning just one resultset from function call with refcursor
Previous Message Francisco Figueiredo Jr. 2004-09-20 22:35:19 Re: Issues regarding code license of ported code.