Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: sequence in trigger
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