RE: Grabbing sequence values blocks in consecutive order: Need a guaranteed method.
Date: Tue, 24 Mar 2009 13:30:02 -0400
Message-ID: <6AFC12B9BFCDEA45B7274C534738067F1400FA1B_at_AAPQMAILBX02V.proque.st>
So, your app needs to grab a block of sequence values....? How large a block?
One possible solution would be to use a sequence w/ increment by <your sequence block size>. So, if you need a block of 10, create a sequence that is "increment by 10", and then each session will select as follows:
Session 1:
Select seq.nextval will get 1
Session 2:
Select seq.nextval will get 11
Session 3:
Select seq.nextval will get 21
Now, in the application logic, it will do 10 inserts, starting with the sequence it fetched. So, session 1 will insert 1-10, 2 will insert 11-20, three will insert 21-30, etc.
You'll have to account how to deal with rollbacks, application crashes, other errors, etc. But, in principle, I think it will work, and still be scalable.
Hope that helps,
-Mark
-----Original Message-----
From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org] On Behalf Of FmHabash
Sent: Tuesday, March 24, 2009 1:21 PM
To: Oracle-L Group
Subject: Grabbing sequence values blocks in consecutive order: Need a guaranteed method.
Hi all,
I have a need for a java app to be able in some guaranteed manner to grab a block of sequence values that are consecutive in order.
Given the fact that there can potentially be multiple sessions making such request, no session should end up interrupting another's while this sequence values block is being granted.
I know this can be done on java side, but thought may be it can also be done on db as well.
My initial review shows that sequences will never guarantee gapless values. If this is the case, can this still be done at least guaranteeing an ordered (not necessarily consecutive ) values?
Thanks
--
http://www.freelists.org/webpage/oracle-l
--
http://www.freelists.org/webpage/oracle-l
Received on Tue Mar 24 2009 - 12:30:02 CDT