you have to refer to the sequence from within an SQL statement. this
should work:
CREATE OR REPLACE TRIGGER TR_ANDY_TEST
BEFORE INSERT ON TB_ANDY_TEST
FOR EACH ROW
BEGIN
select DT_SEQ.NEXTVAL
into :new.dt
from dual;
END;
tzad
> From: ProCard, Inc. <AROBBINS_at_PROCARD.COM>
> Newsgroups: comp.databases.oracle.misc
> Subject: Seqence Number in Triggers Please Help
> Date: Wednesday, March 11, 1998 1:32 AM
>
> Every time a record is inserted into a table I would like the trigger to
> update the PK before insert with a sequence number.
> We are unable to alter our current insert statements to complete the
> operation. The inserts are also used on Ms Sql Server and Ms Access.
> Below I have listed some examples that do not work yet. Please help.
>
>
> Andy Robbins
> ProCard Inc
> arobbins_at_procard.com
> ====================
>
> CREATE OR REPLACE TRIGGER TR_ANDY_TEST
> BEFORE INSERT ON TB_ANDY_TEST
> FOR EACH ROW
> BEGIN
> :NEW.DT= DT_SEQ.NEXTVAL
> END;
> /
>
> CREATE OR REPLACE TRIGGER TR_ANDY_TEST
> BEFORE INSERT ON TB_ANDY_TEST
> FOR EACH ROW
> DECLARE newrow number;
>
> BEGIN
> newrow = DT_SEQ.NEXTVAL
> END;/
>
Received on Tue Mar 10 1998 - 00:00:00 CST