0

I have an INSERT statement with an IGNORE option, because I have a unique field in the insert statement, that is not the primary key. I am using the getGeneratedKeys() command on a PreparedStatement object to get the keys of newly generated rows. Is it possible to configure JDBC in a way so that it returns the id of the ignored row in the case of a query where the IGNORE triggers?

Thomas
  • 10,289
  • 13
  • 39
  • 55

1 Answers1

1

The answer mysql - after insert ignore get primary key seems to indicate that a multi-step workaround is required to retrieve the details of the ignored rows.

With the optional alternative of using REPLACE INTO if you can afford the additional overhead of replacing the rows rather than ignoring them.

Community
  • 1
  • 1
Baxter
  • 2,416
  • 1
  • 22
  • 29