Check for duplicates before inserting

后端 未结 7 584
广开言路
广开言路 2020-12-01 17:38

Before inserting into the database, I\'m using the following code to check for duplicates. To me, a duplicate is only considered a duplicate when name, de

7条回答
  •  我在风中等你
    2020-12-01 17:47

    You can still run into race conditions where 2 users try to insert dups at the same time, checking for dups using a select statement simultaneously gives both users the go ahead to insert their records. I prefer to set unique index on the DB and then catch the error that bubbles up from the DB.

提交回复
热议问题