Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id F37A79FBFE3 for ; Fri, 27 Apr 2007 09:40:41 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 40047-04-2 for ; Fri, 27 Apr 2007 09:40:36 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from beaver.fastcrypt.com (beaver.fastcrypt.com [64.7.141.17]) by postgresql.org (Postfix) with ESMTP id DB8949FBD4C for ; Fri, 27 Apr 2007 09:40:35 -0300 (ADT) Received: from [192.168.1.14] (dcdsl.ebox.com [64.7.143.116]) by beaver.fastcrypt.com (Postfix) with ESMTP id EF7391580627; Fri, 27 Apr 2007 08:46:05 -0400 (EDT) In-Reply-To: <244181.74662.qm@web39109.mail.mud.yahoo.com> References: <244181.74662.qm@web39109.mail.mud.yahoo.com> Mime-Version: 1.0 (Apple Message framework v752.3) Content-Type: multipart/alternative; boundary=Apple-Mail-4--345544461 Message-Id: Cc: pgsql-jdbc@postgresql.org From: Dave Cramer Subject: Re: Refcursor bug Date: Fri, 27 Apr 2007 08:40:34 -0400 To: Altaf Malik X-Mailer: Apple Mail (2.752.3) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/134 X-Sequence-Number: 16983 --Apple-Mail-4--345544461 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Did this work in previous versions ? I made a change recently which closes the refcursor immediately after reading it, because it was leaking on large batches Dave On 27-Apr-07, at 8:20 AM, Altaf Malik wrote: > 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 " 1>" does not exist > > Am i doing something wrong? > > --Altaf Malik > > Ahhh...imagining that irresistible "new car" smell? > Check out new cars at Yahoo! Autos. --Apple-Mail-4--345544461 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1 Did this work in previous = versions ?

I made a = change recently which closes the refcursor immediately after reading it, = because it was leaking on large batches

Dave
On = 27-Apr-07, at 8:20 AM, Altaf Malik wrote:

Hi,
=A0I = 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=A0 int4, b=A0 = varchar);

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

3- Run the = following code:

=A0=A0=A0=A0=A0=A0=A0 = con.setAutoCommit(false);
=A0=A0=A0=A0=A0=A0=A0 CallableStatement stm = =3D con.prepareCall("{call reftwo(?,?)}");=A0=A0=A0=A0=A0=A0=A0 =
=A0=A0=A0=A0=A0=A0=A0 = stm.registerOutParameter(1,Types.OTHER);
=A0=A0=A0=A0=A0=A0=A0 = stm.registerOutParameter(2,Types.OTHER);=A0=A0=A0=A0=A0=A0
=A0=A0=A0=A0= =A0=A0=A0 stm.execute();=A0=A0=A0=A0=A0=A0
=A0=A0=A0=A0=A0=A0=A0 = ResultSet rs =3D (ResultSet) stm.getObject(1);
=A0=A0=A0=A0=A0=A0=A0 = ResultSet rs2 =3D (ResultSet) stm.getObject(2);=A0=A0=A0=A0=A0=A0 =
=A0=A0=A0=A0=A0=A0=A0 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 out new cars at Yahoo! = Autos.

= --Apple-Mail-4--345544461--