CREATE SEQUENCE my_sequence
START WITH 60005963
INCREMENT BY 1
MINVALUE 60005883
MAXVALUE 9999999999
NOCYCLE
CACHE 20
NOORDER
/
The user start generate the check last week and sequence was generated fine from 60005883 to 60005934. So today, when she generate check , we expect to have the check number 60005935 but it disn't generate this number and it generate number 60005943.
1. Why it generated 60005943 instead of 60005935 ???
2. What is the cache mean in the sequences
Probably your application tried to get the number from the sequence and cancelled the transaction before commit. In this case, the sequence # incremented anyway.
If you say CACHE 20, it means Oracle will cache 20 sequential numbers in buffer cache and will make them immediately available to you.
However, if you re-start the database, these 20 numbers would be gone. After the re-start, Oracle would make another set of 20 number available to you in the cache.
Due to which, you would see some difference between the present value and the last value before the database re-start.
Like Shestakov said, use NOCACHE or follow Jeff's advise;
drop it and re-create it appropriately or perhaps, you may want to look into AQ option.
In some cases, programmers would create a table to store
the last value and write a function and call the function in a trigger or call it in the front-end script.
Bookmarks