Re: unique column values

From: <mconnors_at_mother.com>
Date: 1997/09/24
Message-ID: <01bcc8a8$87b9e860$a52168cf_at_mconnors.mother.com>#1/1


Ian -

There is a type of database object called a sequence. Oracle guarantees that each value selected from the sequence will be higher than the last (unless you recycle, but most of the time you needn't worry about that). It is not always sequential, because some values are cached, and can be lost.

What you are describing can be done in a before row database trigger that fires on insert. The code looks something like the below, where id is the column that holds the unique sequential number.

begin
  if :new.id is null then
    /* the if statement is here in case the front end is also populating this column */

    select <sequence_name>.nextval
      into :new.id
    from dual;
  end if;
end; Received on Wed Sep 24 1997 - 00:00:00 CEST

Original text of this message