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

Home -> Community -> Usenet -> c.d.o.server -> REPOST: Re: Newbie: trigger with sequences

REPOST: Re: Newbie: trigger with sequences

From: Howard J. Rogers <dba_at_hjrdba.com>
Date: Fri, 28 Dec 2001 16:44:22 +1100
Message-ID: <7$--$$-$$_%%_$%-_$@news.noc.cabal.int>


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

Original text of this message

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