Need to create sequence so what the code was currently doing select max(name) from table where item1 = '' and item2= '' and item3 = '' . After fetching max then it insert the element starting from max. But it will lead to concurrency issue.
Note: The query will always be perform in same parition
Currently i have two approach:
One to create a sequence table which will contain the ID and sequence as column. Sequence column will contain the last sequence number for that ID. This will be updated using optimistic concurrency.
Second one is to use stored procedure.
But still i am looking for some more better approach if that is present.