Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 85FAC632909 for ; Wed, 25 Nov 2009 07:53:42 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 84978-05 for ; Wed, 25 Nov 2009 11:53:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id C2E5063299C for ; Wed, 25 Nov 2009 07:53:31 -0400 (AST) Received: from list by lo.gmane.org with local (Exim 4.50) id 1NDGR4-0001r8-MQ for pgsql-jdbc@postgresql.org; Wed, 25 Nov 2009 12:53:26 +0100 Received: from 217.110.94.67 ([217.110.94.67]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 25 Nov 2009 12:53:26 +0100 Received: from spam_eater by 217.110.94.67 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 25 Nov 2009 12:53:26 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Thomas Kellerer Subject: Re: getUdateCount() vs. RETURNING clause Date: Wed, 25 Nov 2009 12:53:17 +0100 Lines: 33 Message-ID: References: <4B0C7CFE.50106@opencloud.com> <4B0D1164.1060006@opencloud.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 217.110.94.67 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 In-Reply-To: <4B0D1164.1060006@opencloud.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.264 tagged_above=-10 required=5 tests=AWL=-0.804, BAYES_50=0.001, RCVD_NUMERIC_HELO=2.067 X-Spam-Level: * X-Archive-Number: 200911/26 X-Sequence-Number: 20073 Oliver Jowett, 25.11.2009 12:13: > > You've done some selective editing there. The javadoc I referred to is > this (from the Java 6 javadoc): > > getResultSet(): > > Retrieves the current result as a ResultSet object. This method should > be called only once per result. Correct, once per *result* not per statement. If the statement returns more than one result, I should be allowed to call it multiple time. I think the base of my (mis)understanding is that the term "current" lead me to believe that the "stack" of results a statement can hold, could look like this: resultSet update count = 3 update count = 2 resultSet reslutSet So if I create a loop using the condition stated in the Javadocs the program flow would be as follows: 1) stmt.execute() returns true, so I call getResultSet() 2) getMoreResults() returns false, but getUpdateCount() returns 3 ==> go on 3) getMoreResults() returns false, but getUpdateCount() returns 2 ==> go on 4) getMoreResults() returns true, so getResultSet() returns a result set ==> go on 5) getMoreResults() returns true, so getResultSet() returns a result set ==> go on 6) getMoreResults() returns false, getUpdateCount() returns -1 ==> everything was processed. Apparently this interpretation of "current", "next" and "once per _result_" was wrong... Regards Thomas