Re: Multiple Statement result set problem with PreparedStatements

Поиск
Список
Период
Сортировка
От Oliver Jowett
Тема Re: Multiple Statement result set problem with PreparedStatements
Дата
Msg-id 42D5C283.8010707@opencloud.com
обсуждение исходный текст
Ответ на Multiple Statement result set problem with PreparedStatements ?  ("Lenard, Rohan (Rohan)" <rlenard@avaya.com>)
Список 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 по дате отправления:

Предыдущее
От: "Lenard, Rohan (Rohan)"
Дата:
Сообщение: Re: Multiple Statement result set problem with PreparedStatements ?
Следующее
От:
Дата:
Сообщение: java.sql.SQLException: Cannot instantiate a SerialArray object with null parameters, when using CachedRowSetImpl