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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Autonumber Field in Oracle

Re: Autonumber Field in Oracle

From: Matthias Gresz <GreMa_at_t-online.de>
Date: Tue, 02 Feb 1999 08:47:44 +0100
Message-ID: <36B6ADA0.BAF44C86@Privat.Post.DE>

Chris Capson schrieb:
>
> I am currently migrating a Microsft Access 97 application to Oracle. I have
> created all of my tables but i can't figure out how to handle the autonumber
> field from Microsoft access. This autonumber field should automatically
> increment by one anytime anybody inserts a record into the table. I have
> been reading about it and it sounds like Oracle has some sort of CREATE
> SEQUENTIAL. I am note sure how to set it up so that anytime a record is
> added that the primary key field will be incremented automatically. If
> anybody has any recommendations or examples they would be greatly
> appreciated.
>

You've got to use SEQUENCES and TRIGGERS:

Create Sequence SEQ_DL_Honorar_ID;

create or replace trigger tBI_DL_Honorar before INSERT on DL_Honorar for each row
begin

        SELECT SEQ_DL_Honorare_ID.NEXTVAL INTO :new.HonorarNr FROM DUAL; end;
/

HTH
Matthias
--
Matthias.Gresz_at_Privat.Post.DE

Always log on the bright side of life.
http://www.stone-dead.asn.au/movies/life-of-brian/brian-31.htm Received on Tue Feb 02 1999 - 01:47:44 CST

Original text of this message

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