Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Seqence Number in Triggers Please Help

Re: Seqence Number in Triggers Please Help

From: tzadkiel <tzadkiel_at_surfnetcity.com.au>
Date: 1998/03/10
Message-ID: <01bd4c60$07e40f80$5cce6ccb@default>#1/1

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

Original text of this message

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