Duplicate Generation

Duplicate Generation

  
 Hi Guys,

We have a situation wherein the system we have created, when the 2 or more users click save at the same time, 
the member no. for the data they created is the same.

Example :
User 1 saves member created - M-1001
User 2 saves member created - M-1001

any suggestions on how to have a workaround about this? Is there a way to queue these actions when 2 or more users save at the same time? 


Thanks & Regards,
Lawrence
Hi Lawrence,

How are you generating the numbers?
The easy solution is to let the id's being generated by the tables autonumber identifiers. Note that this won't guarantee that numbers are sequential, there can be gaps if transactions are rollbacked.

If you want to have more control over the numbers, there is also the alternative to have an entity with a single line with the count. Then to get a new number call the GetForUpdate action on that entity. That will cause concurrent requests to wait for the database lock till you call the CommitTransaction action or the request ends.
Just try now to take a long time on your action until you release the lock, as it could give a slowness feeling to the second user if it takes too much.

Regards,
João Rosado