Pavithra wrote:

>       I am having some problem with sequence.
> 
>       This is how i create a sequence. Programming Language - 
> Pro*C ( Linux )
> 
>         CREATE SEQUENCE TransId_Seq
>                         START WITH 1
>                         INCREMENT BY 1
>                         MAXVALUE 100000000
>                         NOCYCLE ;      
> 
>       I entered 10 transaction yesterday. If i enter another 
> transaction today ,the sequence TransId_Seq should start from 
> 11. But it is starting from 22  . We haven't entered any 
> transaction in the mean time . We have tested this several 
> times. The number generated by sequence is not continuous. ( 
> We are using TransId_Seq.NextVal to get the Sequence value )
> 
>       Continuously using sequence does not cause any problem. 
> But if there is a break for 1 or 2 days then we are facing 
> this problem.

Mhm, I believe you did not tell everything.
During those 1 or 2 days there was at least one RESTART of your database.

Let me describe:
per default for every sequence without CACHE/NOCACHE-specification 
implicitly CACHE 20 is used.
This is done to avoid the necessity of logging EVERY nextval-usage.
Only one log-info (for restart) is stored per caching/per 20 numbers.
(Ok, it is not written in the docu. We will do it with the next version)

If you use the sequence for the first time, the (implicitly defined)
minvalue is used,
no caching done.
With the next call of <sequence_name>.nextval caching starts and 20 values
are cached.
These are the values 2 to 21.
You took 9 out of this first cache. Then those 1 or 2 days with at least
one restart came along. The restart knows only the last of that 20 used
(cached) 
numbers, i.e. 21.
And the next nextval-call starts with the next free number known, i.e
the value behind 21, i.e. 22.

To make it short:
use     CACHE 1    and there will be no hole even after Restart.

Elke
SAP Labs Berlin
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to