How to avoid the creation of Duplicate Numbers

Hello,

We have a requirement where we generate a unique number to the customer. The number generation criteria is that, look for the recently created unique number in DB, increment it by 1 and then persist it to the DB. All these rules are carried out in the Button Submit. The Problem here is, when two users Submit the Form at the same time then the Same unique number(Actually Duplicates) is created for them. Is there someway to prevent this ?

Thanks

  Discussion posts and replies are publicly visible

Parents Reply Children
No Data