Home » SQL & PL/SQL » SQL & PL/SQL » problem with sequences
problem with sequences [message #270047] Tue, 25 September 2007 09:00 Go to next message
seenujanu
Messages: 53
Registered: August 2006
Location: chennai
Member
Hi Friends/Seniors,

i had a problem with sequences

i have created a sequence 

CREATE SEQUENCE sathi_seq_s
START WITH 1 
NOMAXVALUE 
MINVALUE 1 
NOCYCLE 
CACHE 20 
NOORDER 

The problem is when i run this 

select LAST_NUMBER from user_sequences where sequence_name = 'sathi_seq_s'

SEQUENCE_NAME	MIN_VALUE	MAX_VALUE	INCREMENT_BY	CYCLE_FLAG	ORDER_FLAG	CACHE_SIZE	LAST_NUMBER	
sathi_seq_s	1	1E+27	1	N	N	20	2961	

after that  i run this Query it shows the value

SELECT sathi_seq_s.nextval from dual

	2944

when i run continously  from 2944 to 2961 

Then again i run the 

select LAST_NUMBER from user_sequences where sequence_name = 'sathi_seq_s'

the previous value get increased from 2961 to 2981 

it showing the error Sequence error....

why this happening like this...


Regards

Seenu
Re: problem with sequences [message #270048 is a reply to message #270047] Tue, 25 September 2007 09:02 Go to previous message
Frank
Messages: 7901
Registered: March 2000
Senior Member
Because of the cache.
If you select a value, it will check the cache for one. If none is there, it will get 20 values, return one to you and cache the other 19.
Not a bug, but a feature that improves performance
Previous Topic: NUMBER column
Next Topic: sort given string alphabetic
Goto Forum:
  


Current Time: Tue Dec 03 10:55:11 CST 2024