Unexplained Behaviour of Sequence in Oracle

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
myfsh1978
Posts: 1
Joined: Mon 30 Sep 2013 09:23

Unexplained Behaviour of Sequence in Oracle

Post by 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

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Unexplained Behaviour of Sequence in Oracle

Post by 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/ser ... sthref5340
http://asktom.oracle.com/pls/apex/f?p=1 ... 0346406705

Post Reply