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