Lenard, Rohan (Rohan) wrote:
> 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());
> }
That should handle the first INSERT.
> else {
> if (getMoreResults()) {
> processRS(stmt.getResultSet()); // only gets called with 1 element
> SELECTED.
> }
> }
That should handle the second INSERT.
You do not appear to be handling the results of the SELECT at all.
Your testcase is not very clear about what you're trying to do and the
incorrect behaviour you see :/
-O