From: Altaf Malik <mmalik_altaf@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: Refcursor bug
Date: Fri, 27 Apr 2007 05:20:04 -0700 (PDT)
Message-ID: <244181.74662.qm@web39109.mail.mud.yahoo.com> (raw)
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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: mmalik_altaf@yahoo.com
Subject: Re: Refcursor bug
In-Reply-To: <244181.74662.qm@web39109.mail.mud.yahoo.com>
References: <244181.74662.qm@web39109.mail.mud.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox