Thanks for the question, Girish.
Asked: November 06, 2015 - 6:09 am UTC
Last updated: November 06, 2015 - 9:08 am UTC
Version: 11.0
Viewed 1000+ times
You Asked
Hi,
We are using sequences with cache to populate key column in Oracle database for OLTP application.When any batch is run in multi-threaded fashion and since sequences are cached will batch picks up same sequence number to populate in PK column which gives to unique constraint error ?.
If such scenario occurred then what is the way to avoid this error
Thanks,
Girish
and Connor said...
No this will not occur - it doesnt matter whether the sequence is cached or not.
One of the reasons we recommend sequences is for this reason, you will never get a duplicate (unless you have explicitly told the sequence to cycle around after a certain limit).
Caching simply means that sequence values can be obtained very efficiently, at the 'expense" of that you might get larger gaps in the numbers if the sequence gets aged out of memory. But the value of sequence should unimportant anyway.
Hope this helps.
Is this answer out of date? If it is, please let us know via a Comment