Re: How to keep the sequence?

From: Terry Hamberger <z51610_at_mip.lasc.lockheed.com>
Date: 13 Jan 1995 14:06:40 GMT
Message-ID: <3f61dg$jbq_at_pong.lasc.lockheed.com>


In article <3f1cok$nq6_at_fred.uswnvg.com>, kimmng_at_pebbles.uswnvg.com (Kim Ng) writes:
>
> Based on your post, manipulating sequence number is the only way to do
> it. Of course, if you have a column somewhere that can identify the
> sequence, use it.

I don't remember the original post, so I'm not certain that a sequence number is the only way to do it. Assuming that this is correct, I'm proposing a better method to accomplish the sequencing.

>
> If you want to insert a record in between, you will have to re-sequence
> the rest of the data. I know, this is ugly. I had to this in one of my
> application. Another option is to use a large step initially and then
> use a smaller steps for inserted records. For example, the first time
> users create the data the sequence was: 1000, 2000, 3000, 4000, .....
> When they insert a record between 1000 and 2000 then you create a
> sequence like 1100 for the new record. Hopefully users never insert
> more than what the "gap" allow. I dislike this method, though.
>

Rather than set a lesser increment for inserted records, a much better method uses (previous+next)/2. This permits a very large number of inserts between two records. The best column definition is NUMBER w/o scale or precision which ensures that the column mask will not fail the insert.

With this method, the initial increment can be 1 and still permit a large number of inserts.

Terry Hamberger
Independent Consultant to
Lockheed Aeronautical Systems Corporation z51610_at_mip.lasc.lockheed.com Received on Fri Jan 13 1995 - 15:06:40 CET

Original text of this message