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

Home -> Community -> Usenet -> c.d.o.tools -> Re: sequences as defaults

Re: sequences as defaults

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: 2000/04/22
Message-ID: <8dqqog$gak$1@nnrp1.deja.com>#1/1

In article <8dqe7c$360$1_at_nnrp1.deja.com>,   arpinog_at_my-deja.com wrote:
> Is it possible to set a sequence as a coumn
> default on a table in Oracle 8? Is there any
> thing similar to a Sybase identity column in
> Oracle?
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

you need a trigger to do this.

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

--
Thomas Kyte                              tkyte_at_us.oracle.com
Oracle Service Industries
http://osi.oracle.com/~tkyte/index.html
--
Opinions are mine and do not necessarily reflect those of Oracle Corp


Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Sat Apr 22 2000 - 00:00:00 CDT

Original text of this message

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