From: | dmp <danap(at)ttc-cmc(dot)net> |
---|---|
To: | Jeremy Whiting <jwhiting(at)redhat(dot)com>, PostgreSQL JDBC <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: Multi insert statement and getUpdateCount(). |
Date: | 2015-03-26 19:41:22 |
Message-ID: | 551460E2.8020501@ttc-cmc.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Adam Mackler | 2015-03-26 23:12:31 | Does PGInterval class handle iso_8601 intervalstyle? |
Previous Message | Jeremy Whiting | 2015-03-26 16:33:29 | Multi insert statement and getUpdateCount(). |