Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: SEQUENCE
On 15-Jul-98 13:41:04 John Bester 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.
Hello John,
try this:
create sequence seq_muffel;
create table muffel
(spalte1 number(3) not null,
spalte2 varchar2(10));
create or replace trigger tib_muffel before insert on muffel
for each row
begin
select seq_muffel.nextval into :new.spalte1 from dual;
end;
/
Then you can do the inserts:
insert into muffel (spalte2) values ('test'); insert into muffel (spalte2) values ('two');
Hope that helps,
Lothar
--
Lothar Armbrüster | lothar.armbruester_at_rheingau.netsurf.de Schulstr. 12 | lothar.armbruester_at_t-online.de D-65375 Oestrich-Winkel |Received on Wed Jul 15 1998 - 13:57:23 CDT
![]() |
![]() |