Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Default value from sequence
> >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