1 2 Previous Next 18 Replies Latest reply: May 4, 2012 8:20 AM by 932957 RSS

    Multiple Inserts with max+1

    932957
      HI.
      I am trying to insert 20k rows into a table that already has 80k rows. The primary key of the column should be max+1 for each insert. There is no sequence created for the same. Any idea how to do it. the below does not work.

      INSERT INTO TBL1
      (SELECT (SELECT MAX(COL_key)+1 FROM TBL1),B,C FROM TBL2);

      All the 20k records that are inserted have same col_key value because col_key is not updated on the fly to generate new max+1.

      Thanks.
        1 2 Previous Next