Multiple Statement result set problem with PreparedStatements ? - Mailing list pgsql-jdbc

From Lenard, Rohan (Rohan)
Subject Multiple Statement result set problem with PreparedStatements ?
Date
Msg-id 2773CAC687FD5F4689F526998C7E4E5F1EF2BC@au3010avexu1.global.avaya.com
Whole thread Raw
Responses Re: Multiple Statement result set problem with PreparedStatements  (Oliver Jowett <oliver@opencloud.com>)
List 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
 
 

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: SQLException: Cannot be less than zero
Next
From: "Lenard, Rohan (Rohan)"
Date:
Subject: Re: Multiple Statement result set problem with PreparedStatements ?