Reputation: 885
What is the best way to handle duplicate insertion?
Either we should check before insertion if item already exist then notify user for duplicate entry or we can handle error message and let user know that its a duplicate entry.
Using first approach will cost us an extra database call.
Or if there is any other better approach to handle this please let me know.
Upvotes: 0
Views: 1474
Reputation: 597
Duplicate insertion is at database level.
Or
Or
Checking Whether data exists before insertion is a expensive call and that too you will have to hit on master so try to avoid that.
Upvotes: 1
Reputation: 4604
The best approach is to use a primary key based on the data. If this is not possible with your data then you'll have to query the database before insertion.
Upvotes: 0