Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: SEQUENCE
"John Bester" <johnb_at_iconnect.co.za> wrote:
>Hi,
>
>I need an example on how to use a SEQUENCE. (Actually, the sequence is not
>so difficult - my problem is the trigger) What I want to do is to set an ID
>column to the next value in a sequence in an (BEFORE?) INSERT trigger.
Assuming you've created a sequence called seq_empno and you want to populate the empno column of the emp table:
create or replace trigger emp_bi
before insert
on emp
for each row
when new.empno is null
begin
select seq_empno.nextval
into :new.empno
from dual;
end;
/
Chris
![]() |
![]() |