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: Trigger for auto-sequencing

Re: Trigger for auto-sequencing

From: Michel Cadot <micadot_at_netcourrier.com>
Date: 2000/05/29
Message-ID: <8gu213$11kd$1@s2.feed.news.oleane.net>#1/1

You can use something like that:

create table t (id integer, col1, col2, ...); create sequence s;

create or replace trigger bi_t
before insert on t
for each row
begin

   select s.nextval into :new.id from dual; end;
/

insert into t (col1, col2, ...) values (...);

then id is filled automatically.

--
Have a nice day
Michel


Tony Horse <tanaks_at_yahoo.com> a écrit dans le message : 3GvY4.1332$6T1.247568_at_news.dircon.co.uk...

> Hi,
>
> If I have a table which has a field that is to be auto-sequenced, how do I
> code the table trigger in order to automatically insert this number? At the
> moment I am using column.nextval() in my main SQL statement, but I'm sure
> that there must be a way of doing it at table level.
>
> Tony
>
>
>
Received on Mon May 29 2000 - 00:00:00 CDT

Original text of this message

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