There are a couple of ways around it: check before you insert and either do an update (if something might have changed) or just don't do anything. If you try INSERT a duplicate values for a primary key (or a unique index) you will always get that error. You will find one matching row, and that your code at the point of the error is trying to insert a second. It isn't saying that there is a duplicate entry in the table already, it is saying that there is already one entry in there with that value for the primary key and it is refusing to insert a second for that reason.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |