Hallo,
here is my oracle table structure:

CREATE TABLE TEAMS ( 
ID NUMBER(38) NOT NULL, 
TEAM VARCHAR2(255), 
DATUM DATE, 
constraint SYS_C0065069 PRIMARY KEY (ID) 
) 
/ 

I added a sequence:

CREATE SEQUENCE teams_seq;

and then a trigger

SQL> create trigger teams_trig 
2 before insert on teams 
3 for each row 
4 begin 
5 select teams_seq.nextval into :new.id from dual; 
6 end; 
7 / 

This should work as an auto increment each time something is inserted via php in the DB.
the php code:

$stmt = ociparse($ora_conn, "insert into teams (team,datum) values ('" .$_POST['team']. "', sysdate)"); 

And it works, but when ID number 9 is achieved, item 10 becomes an ID 21 and not ten, as it is supposed.
the table looks like this:

id team date

1 1 26.06.2006
2 2 26.06.2006
3 3 26.06.2006
4 4 26.06.2006
5 5 26.06.2006
6 6 26.06.2006
7 7 26.06.2006
8 8 26.06.2006
9 9 26.06.2006
10 11 26.06.2006
11 12 26.06.2006
12 13 26.06.2006
13 14 26.06.2006
14 15 26.06.2006
15 16 26.06.2006
16 17 26.06.2006
17 18 26.06.2006
18 19 26.06.2006
19 20 26.06.2006
20 21 26.06.2006
21 10 26.06.2006
41 22 26.06.2006

Anyone has an idea why is this happening?
thanks in advance
babil

    check that you are not running on a cluster, where the sequence is set for a range on each machine (1-10, 11-20 etc)...

    This highlights the dangers of a sequence which you should never count on to be in order

      Write a Reply...