Re: How mimic autonumber for IDs?

From: Tom Grenier <tom_at_sqlman.com>
Date: Fri, 09 Mar 2001 23:38:07 -0500
Message-ID: <3AA9AFAE.2A18A3E9_at_sqlman.com>


Matt,
There is no need for the trigger. Just use this:

INSERT INTO a_table VALUES (

    test_seq.NEXTVAL,
    val1,
    val2,
    etc);

Tom

Matt Mason wrote:

> Jim-
> I created my sequence and a trigger doing this, but how do I increment my
> sequence? Each time I keep getting 1 as the new ID:
>
> create sequence TEST_SEQ start with 1;
> CREATE OR REPLACE TRIGGER MY_TEST_TRG
> BEFORE INSERT on MY_TEST_TABLE
> FOR EACH ROW
> BEGIN
> SELECT TEST_SEQ.NEXTVAL
> INTO :NEW.ID FROM DUAL;
> END MY_TEST_TRG;
>
> Jim Kennedy <kennedy-family_at_home.com> wrote in message
> news:ywWp6.529210$U46.15894364_at_news1.sttls1.wa.home.com...
> > Use sequences. I think this has been addresses at least 1/week in this
> > newsgroup.
> > Jim
> >
Received on Sat Mar 10 2001 - 05:38:07 CET

Original text of this message