| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Autonumber Field in Oracle
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
![]() |
![]() |