Multiple Statement result set problem with PreparedStatements ?

From: "Lenard, Rohan (Rohan)" <rlenard(at)avaya(dot)com>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Multiple Statement result set problem with PreparedStatements ?
Date: 2005-07-14 00:50:44
Message-ID: 2773CAC687FD5F4689F526998C7E4E5F1EF2BC@au3010avexu1.global.avaya.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

I have SQL like this (foo has a pkey from a serial) -

INSERT INTO foo ( a, b ) VALUES ( ?, ? );
INSERT INTO bar ( foo_fkey, c ) VALUES ( ?, currval('foo_seq'::text) );
SELECT currval('bar_seq'::text) AS x, currval('foo_seq'::text) AS y;

that I'm using like this

final PreparedStatement stmt = conn.createPreparedStatement("
INSERT INTO foo ( a, b ) VALUES ( ?, ? );
INSERT INTO bar ( foo_fkey, c ) VALUES ( ?, currval('foo_seq'::text) );
SELECT currval('bar_seq'::text), currval('foo_seq'::text);");

stmt.setString(1, "A");
stmt.setString(2, "B");
stmt.setString(3, "C");

boolean result = stmt.execute();
if (result) {
processRS(stmt.getResultSet());
}
else {
if (getMoreResults()) {
processRS(stmt.getResultSet()); // only gets called with 1 element
SELECTED.
}
}

This works fine if the SELECT returns 1 value only, but as soon as it
returns 2 values the inserts work but no results are given... What the
???

I have pg-8.0-311 against a 7.3.10 server..


Any ideas ?

Thx,
Rohan


Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2005-07-14 01:40:19 Re: Multiple Statement result set problem with PreparedStatements
Previous Message Kris Jurka 2005-07-13 17:27:54 Re: SQLException: Cannot be less than zero