I have written a web service. It returns a number based on todays date+count
eg 201408111 will be first number returned when it is hit on 11th August 2014 first time.
Second time it will return 201408112, third time 201408112....same on
the initial date remains todays date and concatenate with the number of times it is called.
How its currently implemented is each time a hit comes it fetches the last record in a column and returns it
and then inserts a new row with next column value. So next time the service automatically returns the last column and adds the next.
Problem with this approach is that there can be synchronization or race condition issues.
Like if two there are multiple requests from different machines. They may get the same number resulting in inconsistency.
Please suggest how to avoid this.