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

Home -> Community -> Usenet -> c.d.o.server -> Re: Default value from sequence

Re: Default value from sequence

From: Joel Brueziere <joel.brueziere_at_urbanet.ch>
Date: Sat, 31 Jul 1999 15:46:20 +0200
Message-ID: <7nuunc$l6u$1@news.interpoint.ch>


> >I'm a simple question: i have a table xyz where is column ID and it is
> >primary key. How i can set default value from sequence MYSEQ for this
> >column? The line in "ID NUMBER DEFAULT myseq.nextval" in CREATE TABLE or
> >ALTER TABLE statement is not allowed.

Like this:

create sequence address_book_seq START WITH 1 increment by 1;

CREATE or REPLACE TRIGGER address_book_trig BEFORE INSERT ON address_book FOR EACH ROW
BEGIN   SELECT address_book_seq.NEXTVAL INTO :new.addr_idtech FROM DUAL;

END;
/

Joel Brueziere
http://www.decollage.org/joelbr/
Paragliding, WebCam lac Leman
joel.brueziere_at_urbanet.ch Received on Sat Jul 31 1999 - 08:46:20 CDT

Original text of this message

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