pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Altaf Malik <mmalik_altaf@yahoo.com>
To: Dave Cramer <pg@fastcrypt.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Refcursor bug
Date: Fri, 27 Apr 2007 06:02:44 -0700 (PDT)
Message-ID: <490539.96653.qm@web39115.mail.mud.yahoo.com> (raw)
In-Reply-To: <E8896A9E-6102-4733-B0BA-0322028B7821@fastcrypt.com>

Yes this worked in previous versions.

As you close the cursor say '<unnamed portal 1>' when you fetch it, it closes the underlying cursor. And the send variable also points to the same variable, and you send a FETCH ALL..... which throws exception because cursor has already been closed.

--Altaf

Dave Cramer <pg@fastcrypt.com> wrote: 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 "<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.




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

view thread (6+ messages)  latest in thread

Message-ID: <490539.96653.qm@web39115.mail.mud.yahoo.com>
Permalink:  ../490539.96653.qm@web39115.mail.mud.yahoo.com/
Also on:    postgresql.org/message-id/490539.96653.qm@web39115.mail.mud.yahoo.com

 · 

reply

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, pg@fastcrypt.com
  Subject: Re: Refcursor bug
  In-Reply-To: <490539.96653.qm@web39115.mail.mud.yahoo.com>
  References: <E8896A9E-6102-4733-B0BA-0322028B7821@fastcrypt.com> <490539.96653.qm@web39115.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