Recycled Sequence Numbers
Hi,
We have a requirement of generating sequence numbers for a table and we need to recycle them if some of them is deleted.
For example the following tabe Employee(Id,name)
ID NAME
1 XXX
2 YYY
3 ZZZ
4 AAA
The ID filed should have the next sequence number generated. When I call getnextID now, it should return 5
ID NAME
1 XXX
2 YYY
3 ZZZ
4 AAA
5 BBB
Now Let us assume I delete 3. The contents of the table aare
ID NAME
1 XXX
2 YYY
4 AAA
5 BBB
Now when getNextID, 3 should be returned.
How to achieve this in a best performing way in Oracle? Are there any patterns around it? Please note this should run in a multi user environment.
Thanks,
Rama