Sequence Numbers

From: Stan Driggs <stan_at_lfs.loral.com>
Date: 1995/04/03
Message-ID: <3lpa1l$n17_at_watnews1.watson.ibm.com>#1/1


As long as we are discussing sequence numbers, does anyone have an answer to this question:

How can you get a sequence that never issues a number that is already in use in a table?

Sequence numbers are obviously most useful for creating unique numbers that can be used as keys. The problem is, you run out of numbers at some point (before infinity), so the sequence must cycle. Now, if you are using the sequence numbers as a primary key in a table, there is no way to tell if the next sequence number in already in the table (i.e. it is really not available). The only way I can think of to test this is to search the table, or insert the record and wait for a failure. Neither option is very efficient.

Any one have a better way? I just can't believe that there is no reliable mechanism for generating primary key values.

Stan Received on Mon Apr 03 1995 - 00:00:00 CEST

Original text of this message