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: <nasof_at_hotmail.com>
Date: Tue, 08 Sep 1998 17:45:14 GMT
Message-ID: <6t3qfa$utl$1@nnrp1.dejanews.com>


I think you want this trigger to be a "BEFORE" trigger,

otherwise you get an error like:
ORA-04084: cannot change NEW values for this trigger type

You cant insert a null primary key value (column "x" in your table) _then_ update it with an unique sequence...

-Frank

In article <35ff2e57.9686478_at_192.86.155.100>,   tkyte_at_us.oracle.com wrote:
> 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.
>

-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum Received on Tue Sep 08 1998 - 12:45:14 CDT

Original text of this message

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