Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Problem with autosequence

Re: Problem with autosequence

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: Fri, 01 Sep 2000 21:59:07 +0800
Message-ID: <39AFB62B.2206@yahoo.com>

javah_at_njet.com wrote:
>
> Hi.
>
> I am in trouble with the auto sequence.
> I have multible tables in db. And each table has its sequence, eg.
>
> TABLE CREATED THIS WAY:
>
> create table test(
> test_id number(20) primary key,
> other_id number(20),
> name varchar(128));
>
> SEQUENCE THIS WAY:
>
> create sequence test_id_seq
> start with 1
> increment by 1;
>
> And I add the information into the table this way:
>
> insert into test (test_id, order_id, name) values (test_id_seq.nextval,
> 12, "asdf");
>
> Which works pretty nicely... But the ID doesn´t increment by 1 as it is
> supposed to. Or doesn´t do it all the time by one. Sometimes the gap can
> be about 20 sometimes 1... Sometimes something else. I haven´t got a
> clue what defines the increment or why do some numbers get skipped.
>
> The whole insert sentence is constructed with some php code, yes. But
> the name of the sequence and the name of the table is coming from
> exactly the same variable, so if the variable is wrong the sentence
> wouldn´t go thru anyway...
>
> Also the inserts are done thru web pages, so the connection is opened
> and closed frequently, and it does seem a bit like the longer gaps comes
> between every connection... Weird for me, but my Oracle knowledge is
> limited. Might be possible that I have missed something vital here?
> Maybe the sequence on its own is not enough???
>
> Help me out here, anyone who has more clue out of Oracle...
>
> -javah
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

Are gaps such a large problem - remember that typically you want a sequence to give you a unique set of values...Don't over infer what they really mean...

No gaps = big problems in terms of performance...

HTH

-- 
===========================================
Connor McDonald
http://www.oracledba.co.uk

We are born naked, wet and hungry...then things get worse
Received on Fri Sep 01 2000 - 08:59:07 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US