Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YbDVc-0003y4-LB for pgsql-jdbc@arkaria.postgresql.org; Thu, 26 Mar 2015 19:32:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YbDVb-0006II-SH for pgsql-jdbc@arkaria.postgresql.org; Thu, 26 Mar 2015 19:32:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YbDVb-0006IB-04 for pgsql-jdbc@postgresql.org; Thu, 26 Mar 2015 19:32:03 +0000 Received: from rad0.itstriangle.com ([199.38.107.90]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YbDVV-000885-22 for pgsql-jdbc@postgresql.org; Thu, 26 Mar 2015 19:32:00 +0000 Received: from itstriangle.com (localhost [127.0.0.1]) by rad0.itstriangle.com (8.14.4/8.14.4) with ESMTP id t2QJVo0H014940; Thu, 26 Mar 2015 15:31:51 -0400 Received: FROM [192.168.157.52] ([65.19.243.151]) BY itstriangle.com WITH ESMTP ; Thu, 26 Mar 2015 15:31:49 -0400 Message-ID: <551460E2.8020501@ttc-cmc.net> Date: Thu, 26 Mar 2015 13:41:22 -0600 From: dmp User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Firefox/24.0 SeaMonkey/2.21 MIME-Version: 1.0 To: Jeremy Whiting , PostgreSQL JDBC Subject: Re: Multi insert statement and getUpdateCount(). References: <551434D9.6040906@redhat.com> In-Reply-To: <551434D9.6040906@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Jeremy Whiting wrote: > Hi, > I have been testing the current version of pgjdbc master branch. I added a > test case to a branch in my repo [1] to check the behaviour when a multi insert > statement adds two rows to a table. I found the return value when calling > .getUpdateCount() does not equal the number of rows affected. > > My question is what should the return value for .getUpdateCount() represent. > Is it the number of statements executed or rows put in the database ? > > Regards, > Jeremy > > [1] https://github.com/whitingjr/pgjdbc/tree/updatecount-mismatches-updatecount > My quick test shows it seems to be represent the the rows effected. That is using a single statement with multiple insert values. (3) INSERT INTO "public"."key_table4" ("avatar_id", "user_id", "bing_id") VALUES (3, 21, 20), (5, 17, 31), (8, 5, 7); If you are using single insert statements I would assume it will always return (1). According to the Java API Retrieves the current result as an update count; if the result is a ResultSet object or there are no more results, -1 is returned. This method should be called only once per result. Seems correct, rows effected. Using postgresql-9.4-1200.jdbc4.jar, not current repository though. danap. -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc