pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: David Gagnon <dgagnon@siunik.com>
Cc: pgsql-jdbc@postgresql.org
Cc: pgsql-general@postgresql.org
Subject: Re: [JDBC] plpgsql function with RETURNS SETOF refcursor  AS.  How
Date: Thu, 24 Mar 2005 20:14:41 -0500 (EST)
Message-ID: <Pine.BSO.4.56.0503242002530.10416@leary.csoft.net> (raw)
In-Reply-To: <42436003.3000509@siunik.com>
References: <42434D89.5080104@siunik.com>
	<Pine.BSO.4.56.0503241840570.31387@leary.csoft.net>
	<42436003.3000509@siunik.com>



On Thu, 24 Mar 2005, David Gagnon wrote:

> Hi Kris, 
> 
>    I don't get error with the rsTmp.close() statement but with " 
> (rsTmp.next()) ".  The arraycopy is because I want to shrink the 
> original array (size 50) to it real size.  It's not intended to be a 
> deep copy. 

Right, my bad.  I see nothing wrong with your code, but you haven't 
included a complete example.  There aren't any thread safety problems in 
your code where the executePreparedStatementQueryMultipleCursor function 
is called simultaneously? I've attached the test code I've used to verify 
that this is not a driver problem.

Kris Jurka

Attachments:

MultRefCursor.java (text/plain, 993B) download import java.sql.*; public class MultRefCursor { public static void main(String args[]) throws Exception { Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/jurka","jurka",""); Statement stmt = conn.createStatement(); stmt.execute("CREATE OR REPLACE FUNCTION multcurfunc() RETURNS SETOF refcursor AS 'DECLARE ref1 refcursor; ref2 refcursor; BEGIN OPEN ref1 FOR SELECT 1; RETURN NEXT ref1; OPEN ref2 FOR SELECT 2; RETURN next ref2; RETURN; END;' LANGUAGE plpgsql"); stmt.close(); conn.setAutoCommit(false); PreparedStatement ps = conn.prepareStatement("SELECT * FROM multcurfunc()"); ResultSet rs = ps.executeQuery(); while (rs.next()) { System.out.println(rs.getString(1)); ResultSet rs2 = (ResultSet)rs.getObject(1); while (rs2.next()) { System.out.println(rs2.getInt(1)); } rs2.close(); } rs.close(); ps.close(); conn.close(); } }

view thread (21+ messages)  latest in thread

Message-ID: <Pine.BSO.4.56.0503242002530.10416@leary.csoft.net>
Permalink:  ../Pine.BSO.4.56.0503242002530.10416@leary.csoft.net/
Also on:    postgresql.org/message-id/Pine.BSO.4.56.0503242002530.10416@leary.csoft.net

 · 

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: books@ejurka.com, dgagnon@siunik.com, pgsql-general@postgresql.org
  Subject: Re: [JDBC] plpgsql function with RETURNS SETOF refcursor  AS.  How
  In-Reply-To: <Pine.BSO.4.56.0503242002530.10416@leary.csoft.net>
  References: <42434D89.5080104@siunik.com> <Pine.BSO.4.56.0503241840570.31387@leary.csoft.net> <42436003.3000509@siunik.com> <Pine.BSO.4.56.0503242002530.10416@leary.csoft.net>

* 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