Sequence or Next.Val not incrementing correctly
406777Apr 20 2004 — edited Apr 21 2004Hello,
I've searched this forum for an answer and was unable to find one. I don't see an answer in the manual either.
I've created a sequence and table. The sequence is to increment by 1. For some reason it's not incrementing by 1. It's incrementing by some random number.
Here's a basic example of what the table looks like:
ID | PIDN | studentName
---------------------------
1 | P00542 | Roger
21 | P00875 | Wayne
22 | P00789 | Steve
41 | P00123 | John
I created the table with this:
CREATE TABLE tableName (id VARCHAR(255) NOT NULL PRIMARY KEY, PIDN VARCHAR(10) NOT NULL, studentName VARCHAR(255) NOT NULL)
I created the sequence with this code:
CREATE SEQUENCE auto_increment start with 1 increment by 1 nomaxvalue
Here's my INSERT statement (using PHP):
INSERT INTO tableName (id, PIDN, studentName) VALUES (auto_increment.nextval, '$studentIDVariable', '$nameVariable')
Is there something wrong with my statement(s)? Any idea why it would increment in such a strange manner?
I had to drop this table the first time I created it. Perhaps the original set of ID's are bothering this sequence? To drop the table and sequence I used:
DROP SEQUENCE auto_increment
and then I used:
DROP TABLE tableName CASCADE CONSTRAINTS
Any help is greatly appreciated!!!!
Thanks!