Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> REPOST: 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.
-- Nikki ========= WAS CANCELLED BY =======: Path: news.sol.net!spool1-nwblwi.newsops.execpc.com!newsfeeds.sol.net!news-out.visi.com!hermes.visi.com!uunet!ash.uu.net!sac.uu.net!lax.uu.net!news.navix.net!u-n-c-a-n-c-e-l-l-e-r From: "Nikki Woelk" <nikki_at_faludi.com> Newsgroups: alt.config,comp.lang.c,comp.databases.oracle.server Subject: cmsg cancel <u2nihhio2mdn41_at_corp.supernews.com> Control: cancel <u2nihhio2mdn41_at_corp.supernews.com> Date: Mon, 31 Dec 2001 06:35:46 GMT Organization: The World's Usenet -- http://www.Supernews.com Lines: 2 Message-ID: <cancel.u2nihhio2mdn41_at_corp.supernews.com> NNTP-Posting-Host: 166.102.15.34 X-Trace: iac5.navix.net 1009790247 28060 166.102.15.34 (31 Dec 2001 09:17:27 GMT) X-Complaints-To: abuse_at_navix.net NNTP-Posting-Date: 31 Dec 2001 09:17:27 GMT X-No-Archive: yes Comment: Anarchy! Fuck You! X-Commentary: I love NewsAgent 1.10, Sandblaster Build 74 (19 March 1999) and the Polaris Cancel Engine V. 6.1 X-Unacanc3l: yes This message was cancelled from within Mozilla...notReceived on Thu Dec 27 2001 - 19:26:05 CST