Re: Calling stored functions in executeBatch

Поиск
Список
Период
Сортировка
От Oliver Jowett
Тема Re: Calling stored functions in executeBatch
Дата
Msg-id 4235E866.50100@opencloud.com
обсуждение исходный текст
Ответ на Re: Calling stored functions in executeBatch  (Guy Rouillier <guy-rouillier@speakeasy.net>)
Список pgsql-jdbc
Guy Rouillier wrote:

> Answering the last part of my own question.  I wrote a simple program to
> execute my stored procedure using the call escape mechanism:
>
>     CallableStatement s = conn.prepareCall("{ call insert_t1(?)}");

> Exception caught: org.postgresql.util.PSQLException: A result was
> returned when none was expected.
>
> So my conclusion is that you simply can't use PostgreSQL stored
> functions with batches.

At the moment, no. The { call } escape is currently translated to a
SELECT. I suppose we could do a special case to handle batching of that
(ignoring the "unexpected" resultset because we know there's no real
result there), but it seems pretty hairy, and I think the JDBC spec only
requires INSERT/UPDATE/DELETE to be supported.

> At the very least, warn people that it is possible to get committed
> changes followed by an exception.

Well, that's generally true when using autocommit anyway. Consider a
network or server failure just after the implicit commit but before the
client has seen the response.

-O

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: "Michael Laccetti"
Дата:
Сообщение: Re: RowSet error
Следующее
От: Oliver Jowett
Дата:
Сообщение: Re: problem while running simple java program