Re: Calling stored functions in executeBatch

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Guy Rouillier <guy-rouillier(at)speakeasy(dot)net>
Cc: PostgreSQL JDBC <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Calling stored functions in executeBatch
Date: 2005-03-14 19:39:18
Message-ID: 4235E866.50100@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2005-03-14 19:42:32 Re: problem while running simple java program
Previous Message Michael Laccetti 2005-03-14 16:27:44 Re: RowSet error