Re: Calling stored functions in executeBatch - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: Calling stored functions in executeBatch
Date
Msg-id 4235E866.50100@opencloud.com
Whole thread Raw
In response to Re: Calling stored functions in executeBatch  (Guy Rouillier <guy-rouillier@speakeasy.net>)
List 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 by date:

Previous
From: "Michael Laccetti"
Date:
Subject: Re: RowSet error
Next
From: Oliver Jowett
Date:
Subject: Re: problem while running simple java program