Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Trigger for auto-sequencing
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...Received on Mon May 29 2000 - 00:00:00 CDT
> 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
>
>
>