Refcursor bug

From: Altaf Malik <mmalik_altaf(at)yahoo(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Refcursor bug
Date: 2007-04-27 12:20:04
Message-ID: 244181.74662.qm@web39109.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,
I encountered a bug with refcursors with the latest JDBC driver. I cannot get two refcursors as OUT parameter if both of them point to the same underlying refcursor.

Steps to produce:
1- Create table:
CREATE TABLE testref ( a int4, b varchar);

2-Create the function:
CREATE OR REPLACE FUNCTION reftwo(
A OUT REFCURSOR, B OUT REFCURSOR)
RETURNS record AS $$ DECLARE
V_REF REFCURSOR;
BEGIN
OPEN V_REF FOR SELECT * FROM testref;
A:=V_REF;
B:=V_REF;
END; $$ LANGUAGE 'plpgsql'

3- Run the following code:

con.setAutoCommit(false);
CallableStatement stm = con.prepareCall("{call reftwo(?,?)}");
stm.registerOutParameter(1,Types.OTHER);
stm.registerOutParameter(2,Types.OTHER);
stm.execute();
ResultSet rs = (ResultSet) stm.getObject(1);
ResultSet rs2 = (ResultSet) stm.getObject(2);
con.setAutoCommit(true);

When i execute this code, it reports the following problem:
org.postgresql.util.PSQLException: ERROR: cursor "<unnamed portal 1>" does not exist

Am i doing something wrong?

--Altaf Malik


---------------------------------
Ahhh...imagining that irresistible "new car" smell?
Check outnew cars at Yahoo! Autos.

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2007-04-27 12:40:34 Re: Refcursor bug
Previous Message Craig Servin 2007-04-27 01:11:00 Re: slow jdbc postgres connection