Oracle 10g Sequence Help please?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mattynott
    New Member
    • Mar 2007
    • 4

    Oracle 10g Sequence Help please?

    Hi

    I've created a sequence on a table using oracle 10g express edition by using the following code:

    create sequence referee_seq START WITH 1 INCREMENT BY 1

    I then add a row to my table by using the following code:

    insert into referee values(referee_ seq.NEXTVAL,'', '','','','','', '','','','')

    For some reason its skipping values so my primary keys are goin up in 2's like 2, 4, 6, 8 etc etc even though my increment is set to 1.

    If anyone could shed some light as to what i'm doing wrong it would be greatly appreciated

    Thanks
  • rushdishams
    New Member
    • Mar 2007
    • 24

    #2
    mate, don't know what really happened. because when i tested that in my way, the thing worked as it is meant to be. i am attaching here what i have done so that you can get some sort of help...

    create sequence referee_seq start with 1 increment by 1;

    create table testing(
    id integer,
    name varchar(10),
    primary key(id)
    );

    insert into testing(id,name ) values(referee_ seq.nextval,'A' );
    insert into testing(id,name ) values(referee_ seq.nextval,'B' );
    insert into testing(id,name ) values(referee_ seq.nextval,'C' );
    insert into testing(id,name ) values(referee_ seq.nextval,'D' );
    insert into testing(id,name ) values(referee_ seq.nextval,'E' );

    One thing you can check- the data type of your primary key.

    Comment

    • mattynott
      New Member
      • Mar 2007
      • 4

      #3
      Hi

      Thanks for you help mate

      I tried your test and it worked fine

      I had a look at my table sql and it seems that when it was created it created a trigger to increment the id automatically so when i was calling nextval it was incrementing it twice if you see what i mean.

      Thanx for your help and problem is sorted now

      Comment

      Working...