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 -> Newbie: trigger with sequences

Newbie: trigger with sequences

From: Nikki Woelk <nikki_at_faludi.com>
Date: Thu, 27 Dec 2001 17:26:05 -0800
Message-ID: <u2nihhio2mdn41@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
Received on Thu Dec 27 2001 - 19:26:05 CST

Original text of this message

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