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 -> Guaranteed Order With a Sequence / Trigger

Guaranteed Order With a Sequence / Trigger

From: <john_galt29_at_my-deja.com>
Date: Sun, 24 Oct 1999 02:57:04 GMT
Message-ID: <7utshv$jl7$1@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? Or should I do something at the application level, like lock the table before doing an insert? I would prefer *NOT* to do that ...

Thanks for any help or comments!
John

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Sat Oct 23 1999 - 21:57:04 CDT

Original text of this message

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