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: SERIAL data type

Re: SERIAL data type

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Mon, 07 Sep 1998 19:06:06 GMT
Message-ID: <35ff2e57.9686478@192.86.155.100>


A copy of this was sent to "Alberto Lago da Silva" <alberto.lagodasilva_at_abrantina.pt>
(if that email address didn't require changing) On Mon, 7 Sep 1998 19:29:33 +0100, you wrote:

>Hi,
>
>How do I create de equivalent of the Informix SERIAL data type with Oracle 8
>and Oracle 7.3.
>
>Thanks in advance
>
>als
>

You need a sequence and a trigger -- it would look like this:

create table T1 ( x int primary key, .... );

create sequence t1_x_seq;

create trigger t1_trigg
after insert on t1 for each row
begin

   select t1_x_seq.nextval into :new.x from dual; end;
/  

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA

--
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 Sep 07 1998 - 14:06:06 CDT

Original text of this message

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