Re: HELP: Sequence Problem!!!

From: Arjan van Bentem <avbentem_at_DONT-YOU-DAREdds.nl>
Date: Fri, 31 Jul 1998 12:38:06 +0200
Message-ID: <6ps6pq$g98$1_at_pascal.a2000.nl>


Once you have called nextval in your session, you may use curval. This implies however that you need to be sure that Oracle evaluates the values in the given order:

    strSQL = "INSERT INTO table1 (firstID,secondID) VALUES
(SEQ1.NextVal, seq1.curval) "

I guess you'd better add an extra line to get the nextval into a variable:

    select seq.nextval
    into v_SeqVal
    from dual;

    strSQL = 'INSERT INTO table1 (firstID,secondID) VALUES ( '     || v_SeqVal || ', ' || v_SeqVal || ') ';

Or an update:

    strSQL = "INSERT INTO table1 (firstID,secondID) VALUES
(SEQ1.NextVal, null)"

    update table1
    set secondID = firtstID
    where secondID is null;

Arjan. Received on Fri Jul 31 1998 - 12:38:06 CEST

Original text of this message