X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DD29E567F9 for ; Mon, 14 Mar 2005 19:39:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35753-05 for ; Mon, 14 Mar 2005 19:39:27 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id BC9D2567EB for ; Mon, 14 Mar 2005 19:39:24 +0000 (GMT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1DAvPM-0006uz-00; Tue, 15 Mar 2005 08:39:20 +1300 Message-ID: <4235E866.50100@opencloud.com> Date: Tue, 15 Mar 2005 08:39:18 +1300 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0 (X11/20041228) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Guy Rouillier Cc: PostgreSQL JDBC Subject: Re: Calling stored functions in executeBatch References: <20050311192134.6aad0052@emach> <20050313204039.02ef22fb@emach> In-Reply-To: <20050313204039.02ef22fb@emach> X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/146 X-Sequence-Number: 12538 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