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: sequnce as an id

Re: sequnce as an id

From: Erika Grondzakova <Erika.Grondzakova_at_cern.ch>
Date: Mon, 22 Mar 1999 16:01:19 +0100
Message-ID: <36F65B3F.749108D6@cern.ch>


Hi,

Something like this...

CREATE OR REPLACE TRIGGER unique_x_id

   BEFORE INSERT ON x
   FOR EACH ROW
   BEGIN

     SELECT x.NEXTVAL
       INTO :new.id
       FROM dual;

   END;
/

Erika

Ed Zappulla wrote:
>
> Does anyone know how to specifiy a sequence as a default value for a primary
> key id? I want to do an auto number without having to explicitly set the
> value for each insert. ie:
>
> create sequence seq_id;
>
> create table x
> (
> id number default x.nextval not null, ---- bad syntax.
> how to do this?
> name varchar2(255) not null
> );
>
> insert into x (name) values ('xxxx');
Received on Mon Mar 22 1999 - 09:01:19 CST

Original text of this message

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