Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Sequences in Triggers

Re: Sequences in Triggers

From: Nicolas Bronke <newsgroup_at_trinity.de>
Date: Tue, 19 Oct 1999 17:25:33 +0200
Message-ID: <380c97e8_1@news2.prserv.net>


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

Original text of this message

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