Re: Automatic Numbers with Sequence
Date: 1995/09/15
Message-ID: <No.Account-150995091307_at_nnsgm831.lon40.nt.com>#1/1
In article <43b8ub$7mk_at_ns.access.ch>, integrata_at_access.ch (INTEGRATA AG) wrote:
> Hi there,
> i am looking for a nice way to implement automatic numbering (keys)
> within an oracle database.
> all i could find up to now, is using a sequence and a trigger,
> that always selects the next key from a dummy table before an insert.
> is this the only (and/or) best way to do it ????
>
> Hauke
You do not need to select the next key before the insert. It forms part of the insert. Which insert you use depends on whether you are inserting a set of fixed values, or values derived from a select from another table.
For example:
insert into my_table (key, col_1, col_2) values (my_sequence.nextval, 'SOME STRING', 'ANOTHER STRING');
or
insert into my_table (key, col_1, col_2) select my_sequence.nextval, some_column, 'SOME STRING' from another_table;
Hope this helps!
Nick
Received on Fri Sep 15 1995 - 00:00:00 CEST