Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: CREATING SEQUENCES - HELP PLEASE
In article <344B2AC6.47A5_at_bitel.es>, Javier Riera <javier_at_bitel.es>
writes
>I am trying to build a table where the identifier must autocalculates
>its own value. Has the sequence object this property?
>I created a secuence as:
>
>CREATE SEQUENCE miSeq
> INCREMENT BY 1
> START WITH 0
> MINVALUE 0
> MAXVALUE 9999999
> NOCYCLE
> CACHE 20
> NOORDER
>;
>
>How can I assign this sequence to my table's identifier?
>
>Thanks.
If you want the identifier to have a unique value, you will need to call
the sequence explicitly e.g.
INSERT INTO my_table
( mi_id, mi_value ) VALUES ( miSeq.NEXTVAL, 'a value' );
You could also assign the identifier through a database trigger on the table.
Andy
-- Andy Hardy Senior IT Systems Engineer Cegelec AEG ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Opinions are mine and do not necessarily reflect those of Cegelec AEGReceived on Wed Oct 29 1997 - 00:00:00 CST