Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Sequences in Triggers
Try this
CREATE OR REPLACE TRIGGER test_trigger
BEFORE INSERT ON test_table
FOR EACH ROW
as
declare n number
BEGIN
select test_seq.nextval into N from dual;
:newid_nbr := N;
END;
/
regards
Nicolas Bronke
> Is it possible to use a trigger to populate a column with a sequence
value?
> It's a long story why I need to do it with a trigger rather than via a
> select statement. This trigger compiles, but I get an error message:
>
> SQL> CREATE OR REPLACE TRIGGER test_trigger
> 2 BEFORE INSERT ON test_table
> 3 FOR EACH ROW
> 4 BEGIN
> 5 UPDATE test_table set id_nbr = (select test_seq.nextval from dual);
> 6
> 6 END;
> 7 /
>
Received on Tue Oct 19 1999 - 10:25:33 CDT