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: How to Generate Auto Number

Re: How to Generate Auto Number

From: Steve McDaniels <steve.mcdaniels_at_sierra.com>
Date: Fri, 1 Sep 2000 16:04:48 -0700
Message-ID: <8opcil$rqq$1@spiney.sierra.com>

create sequence SEQ_MYTABLE_ID start with 1 increment by 1;

create trigger TR_MYTABLE_ID
before insert on MYTABLE
for each row
begin
  select SEQ_MYTABLE_ID.nextval into :new.MYTABLE_PK_FIELD_NAME from dual; end;

insert into MYTABLE values (Null, field2, field3, ...);

place a null in the PK field during the insert.

"Arun Solleti" <solleti_at_eng.usf.edu> wrote in message news:39B02569.107AA306_at_eng.usf.edu...
> Hi
>
> Can anyone tell me, what is the data type which will generate a primary
> key for a given table. It is like AutoNumber in access which can be set
> as the primary key. How to set the starting point for this and
> incremental value.
>
> Thanks
> Arun
>
Received on Fri Sep 01 2000 - 18:04:48 CDT

Original text of this message

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