Unexplained Behaviour of Sequence in Oracle

Unexplained Behaviour of Sequence in Oracle

Postby myfsh1978 » Mon 30 Sep 2013 09:32

Dear all

I am using dotConnect For Oracle version 6.60.268.

I create a sequence in Oracle 10g as below:
CREATE SEQUENCE MYSEQUENCE
MINVALUE 0 MAXVALUE 999999999999999 INCREMENT BY 1
START WITH 1 CACHE 100 NOORDER NOCYCLE;


Then in my .NET code, I have integrated the dotConnect For Oracle into the Enterprise library and this is how I get the sequence value:

Return DirectCast(oDalc.RunDirectSQLScalar("SELECT MYSEQUENCE.NEXTVAL FROM DUAL"), Decimal)


Now is the unexplained part:
I have 2 separate .NET exe which will get the sequence value at the same time. The first program get 1 and the second program get 100. This is not what I expected.

I expect the first program get 1 and the second program get 2.

Is there anything wrong with the version of dotConnect For Oracle or is there anything wrong with the sequence that I create?

Please kindly advise.

Thanks
myfsh1978
 
Posts: 1
Joined: Mon 30 Sep 2013 09:23

Re: Unexplained Behaviour of Sequence in Oracle

Postby Pinturiccio » Mon 30 Sep 2013 13:15

myfsh1978 wrote:Is there anything wrong with the version of dotConnect For Oracle or is there anything wrong with the sequence that I create?

The described behavior is not related to dotConnect for Oracle; it is caused by the definition of your sequence. You use CACHE 100 in your sequence definition. When your first application gets the sequence value, 100 values are cached. And when the second application gets the sequence value, it gets the next free sequence value - 100. For more information, please refer to
http://docs.oracle.com/cd/B12037_01/server.101/b10759/statements_6014.htm#sthref5340
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:369390500346406705
Pinturiccio
Devart Team
 
Posts: 2046
Joined: Wed 02 Nov 2011 09:44


Return to dotConnect for Oracle