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: sequence in trigger

Re: sequence in trigger

From: Jonathan Gennick <gennick_at_worldnet.att.net>
Date: 1998/04/01
Message-ID: <6fsdfe$3v6@bgtnsc02.worldnet.att.net>#1/1

On Tue, 31 Mar 1998 14:06:42 -0800, Jim Poe <jpoe_at_fulcrumit.com> wrote:

>I need an example of using a sequence in a trigger. I tried this, but
>I get a compiler error saying that the sequence cannot be referrenced in
>this context.

You need to select NEXTVAL from dual. See my modifications below.
>
>CREATE TRIGGER CUSTOMER_BEF_INS_KEY_ID
> BEFORE INSERT
> ON JIM.CUSTOMER
> FOR EACH ROW

         declare
			nextkey	number;		

> BEGIN
select customer_sequence.nextval into nextkey from dual;
> :new.KEY_ID:=nextkey;
> END;

It's the only way. Received on Wed Apr 01 1998 - 00:00:00 CST

Original text of this message

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