Answer the question
In order to leave comments, you need to log in
Ignoring duplicate error when inserting record in MySQL
Good afternoon!
I again met such a problem. There is a ready-made application that inserts records into the database through MySQL ODBC. There is a base to which I have access. In the database, I need the records to be unique and therefore I create a unique key.
But there are times when the application needs to be restarted and then it starts writing data again and an error message box is displayed for each record that there is already a record with the same identifier. Everything seems to be fine, but! There are a lot of records, about 10000, and the application just hangs.
And I cannot change request for INSERT IGNORE in application. I only have access to the database and to the ODBC driver. Here it is necessary somehow through the settings of the database or the trigger.
Answer the question
In order to leave comments, you need to log in
Are the string values old or new?
If only new ones, then remove the duplicate row from the before insert trigger. A crutch, but should work.
If old - you can rummage here . Or absolutely a crutch: to remove a unique index and the trigger after an insertion to delete an extra line.
You can add to the end of the query ON DUPLICATE KEY UPDATE myvalue=VALUES(myvalue)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question