From: Kris Jurka <books@ejurka.com>
To: Andrés Luna <aluna@ifxcorp.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Getting Reference cursors
Date: Mon, 13 Jun 2005 10:33:33 -0500 (EST)
Message-ID: <Pine.BSO.4.56.0506131030250.10929@leary.csoft.net> (raw)
In-Reply-To: <000801c57019$bf1588c0$ab78100a@ifx.local>
References: <000801c57019$bf1588c0$ab78100a@ifx.local>
On Mon, 13 Jun 2005, [iso-8859-1] Andrés Luna wrote:
> Thanks for your quick answer. However, now I change to the 8.0 driver
> and still doesn´t work. The same code now fails during stored procedure
> execution. Here is the stack trace.
>
> java.sql.SQLException: ERROR: cursor "<unnamed portal 1>" does not exist
I'm not sure why this is happening, perhaps you have autocommit on?
Although that should have caused a failure with the 7.4 driver as well.
I've attached the test case I used to verify this works. Could you show
us the code that is failing here?
Kris Jurka
Attachments:CursorMD.java (text/plain, 1.1K) download
import java.sql.*;
public class CursorMD {
public static void main(String args[]) throws Exception {
Class.forName("org.postgresql.Driver");
Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/jurka","jurka","");
conn.setAutoCommit(false);
Statement stmt = conn.createStatement();
stmt.execute("CREATE TEMP TABLE curtable (a int, b int)");
stmt.execute("INSERT INTO curtable VALUES (1,2)");
stmt.execute("CREATE OR REPLACE FUNCTION curfun() RETURNS refcursor AS 'DECLARE ref refcursor; BEGIN OPEN ref FOR SELECT a,b FROM curtable; RETURN ref; END; ' LANGUAGE plpgsql");
stmt.close();
CallableStatement cs = conn.prepareCall("{ ? = call curfun() }");
cs.registerOutParameter(1, Types.OTHER);
cs.execute();
ResultSet rs = (ResultSet)cs.getObject(1);
ResultSetMetaData rsmd = rs.getMetaData();
System.err.println(rsmd.getColumnCount());
System.err.println(rsmd.getColumnTypeName(1));
System.err.println(rsmd.getColumnTypeName(2));
rs.next();
System.err.println(rs.getInt(1));
rs.close();
cs.close();
conn.close();
}
}
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, aluna@ifxcorp.com
Subject: Re: Getting Reference cursors
In-Reply-To: <Pine.BSO.4.56.0506131030250.10929@leary.csoft.net>
References: <000801c57019$bf1588c0$ab78100a@ifx.local> <Pine.BSO.4.56.0506131030250.10929@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