| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Newbie: trigger with sequences
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.
-- NikkiReceived on Thu Dec 27 2001 - 19:26:05 CST
![]()  | 
![]()  |