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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Guaranteed Order With a Sequence / Trigger

Re: Guaranteed Order With a Sequence / Trigger

From: -=< a q u a b u b b l e >=- <aquabubble_at_Remove.No.Parma.Ham.Remove.geocities.com>
Date: Sun, 24 Oct 1999 12:22:24 +0100
Message-ID: <7uuqag$ptm$1@uranium.btinternet.com>


<john_galt29_at_my-deja.com> wrote in message news:7utshv$jl7$1_at_nnrp1.deja.com...
> I would like to use a certain column in my table to perform some
> calculations and as such I need to be sure of the numbers that are in
> that column. Specifically I want that column to start with the value 1
> and go up from there, incremented by 1 every time a record is added. I
> am using the following sequence / trigger combo:
>
> CREATE SEQUENCE myTableSeq1 INCREMENT BY 1 START WITH 1 ORDER NOCACHE;
>
> CREATE OR REPLACE TRIGGER myTableT1 BEFORE INSERT ON myTable
> FOR EACH ROW
> BEGIN
> SELECT myTableSeq1.nextval INTO :new.id FROM dual;
> END;
>
> Does this ABSOLUTELY GUARANTEE that the sequence will NEVER be out of
> order, that there will never be a gap in the numbers?

Yes! Even if lots of processes are trying to insert at the same (apparent) time. Received on Sun Oct 24 1999 - 06:22:24 CDT

Original text of this message

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