I know this issue can be solved using unique key constraint on column and some insert command variation.
But I exactly want to know that at last why the following approach goes wrong sometimes and a duplicate entry is added:
- a value is checked in the column
- if record returns is > 0 then update is issued, otherwise simple insert command
Most of the times it works. You can say more than 98%, but why does it fail sometimes?
I just want to understand where the glitch is in this approach because record existence is checked first.