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 -> Re: Using Triggers and Sequences

Re: Using Triggers and Sequences

From: Darren Mallette <khs_riderx_at_geocities.com>
Date: 1998/03/24
Message-ID: <3517dd12.62434641@207.93.1.8>#1/1

"Mark Powell" <mark_at_u-net.net> wrote:

>CREATE OR REPLACE TRIGGER USER.SUBS_TRIG
>BEFORE INSERT OR UPDATE OF AG_NUM ON USER.E_SUBS
>FOR EACH ROW
>WHEN (new.AG_NUM = 0 )
>BEGIN
> :new.AG_NUM := USER.S_AG_NUM.NEXTVAL;
>END;
>
>Any help would be gratefully appreciated (as I'm pulling my hair out!)
>

Try:

CREATE OR REPLACE TRIGGER USER.SUBS_TRIG BEFORE INSERT OR UPDATE OF AG_NUM ON USER.E_SUBS FOR EACH ROW
WHEN (new.AG_NUM = 0 )
declare

        v_seq number;

BEGIN

	select user.s_ag_num.nextval
	into v_seq
	from dual;

	 :new.AG_NUM := v_seq;

END; -Darren
--
Remove the "x" to reply.
Received on Tue Mar 24 1998 - 00:00:00 CST

Original text of this message

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