Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> REPOST: Re: Newbie: trigger with sequences
There's an article about this on my website (www.hjrdba.com). Have a look
under the Administration tips for an article called (something like) 'is
there an Oracle equivalent of an autonumber field'.
Regards
HJR
"Nikki Woelk" <nikki_at_faludi.com> wrote in message
news:u2nihhio2mdn41_at_corp.supernews.com...
> Is there anyway to create a trigger that will automatically populate the
> primary key field with the NEXTVAL from the sequence for that table? I
> tried something like this (with sequence emp_ids already created):
>
> CREATE OR REPLACE trigger EMP_TRIG
> before insert on EMP
> for each row
> begin
> :new.empno := emp_ids.NEXTVAL;
> end EMP_TRIG;
> /
>
> but it returns with an error that "Sequence reference 'EMP_IDS.NEXTVAL'
not
> allowed in this context".
>
> Thanks.
> --
> Nikki
>
>
This message was cancelled from within Mozilla...not Received on Thu Dec 27 2001 - 23:44:22 CST