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