I have an existing sequence called TOPICSEQ in the database(oracle), there is a table called t_topic whose id is incremented using this TOPICSEQ. The detail of this seq is created like following CREATE SEQUENCE TOPICSEQ INCREMENT BY 1 START WITH 1001 MAXVALUE 9999 MINVALUE 1 NOCYCLE CACHE 20 NOORDER; It works fine when populating the db with scripts, but when inserting the data using the format like this: String insertTopic="INSERT INTO T_TOPIC VALUES (TOPICSEQ.NEXTVAL,?,0,'unchecked')"; the last topicID is 1006 in the table before I insert the data , after the insertion, the ID becomes 1021. I don't know what the hell it is and I thought it should follow the sequence since I specified the name of the sequence.
Please, just a week I have to submit my project. Any idea will be appreciated. Thanks a lot!
Jian, The "cache 20" tells oracle to reserve groups of 20 ids at a time. When your script ran, it probably got allocated 1000-1020. Then, when you ran using a different client (jdbc) it got from the next available group. Thus 1021.