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

From Oliver Jowett
Subject Re: Multiple Statement result set problem with PreparedStatements
Date
Msg-id 42D5C283.8010707@opencloud.com
Whole thread Raw
In response to Multiple Statement result set problem with PreparedStatements ?  ("Lenard, Rohan (Rohan)" <rlenard@avaya.com>)
List pgsql-jdbc
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

pgsql-jdbc by date:

Previous
From: "Lenard, Rohan (Rohan)"
Date:
Subject: Re: Multiple Statement result set problem with PreparedStatements ?
Next
From:
Date:
Subject: java.sql.SQLException: Cannot instantiate a SerialArray object with null parameters, when using CachedRowSetImpl