Re: Questions on getGeneratedKeys with on duplicate key update cause
This is so because when ON DUPLICATE KEY UPDATE is used there's no way of obtaining the real number of added rows, so, only the first generated ID is returned.
And Connector/J is not able to get the real number of new rows because the way MySQL reports the affected rows count from the INSERT:
Quote
With ON DUPLICATE KEY UPDATE, the affected-rows value per row is 1 if the row is inserted as a new row, 2 if an existing row is updated, and 0 if an existing row is set to its current values.
in
INSERT ... ON DUPLICATE KEY UPDATE Statement.
Connector/J does provide an option that tries to minimize the chance of wrong affected rows counts -
compensateOnDuplicateKeyUpdateCounts - but that's not reliable either.
Subject
Written By
Posted
Re: Questions on getGeneratedKeys with on duplicate key update cause
March 16, 2022 12:43PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.