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: auto-incremental fields ?

Re: auto-incremental fields ?

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Tue, 09 Feb 1999 00:33:42 GMT
Message-ID: <36bf8232.2970621@192.86.155.100>


A copy of this was sent to "AGRISOFT/ABSILOG" <andreu_at_club-internet.fr> (if that email address didn't require changing) On Mon, 8 Feb 1999 19:44:38 +0100, you wrote:

> if the best way to have auto-incremental field for my primary key is to
>fire a trigger, what could be this good trigger ?
>
> if u have one be pleased to send it to me...
>
>jo :)
>
>thx !!!
>

SQL> create sequence my_sequence;

SQL> create or replace trigger my_trigger
   > before insert on T
   > for each row
   > begin
   >    select my_sequence.nextval into :new.my_primary_key from dual;
   > end;
   > /


 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Service Industries
Reston, VA USA

--
http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Mon Feb 08 1999 - 18:33:42 CST

Original text of this message

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