Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005
    Posts
    9

    Unanswered: INSERT INTO ... SELECT query

    Hi,

    I have a simple question:

    In the following query

    INSERT INTO TBL1
    SELECT "?" , 'test', Column3
    FROM TBL1 WHERE Column3='condition'

    Now the SELECT query returns me a set of rows, can I use the above query such that for the first parameter "?" I have a sequence of Ids generated, for each row returned by the SELECT clause.

    Thanks.

  2. #2
    Join Date
    Aug 2004
    Location
    France
    Posts
    754
    Just create a sequence seq1 like that for example :

    Code:
    Create sequence seq1 START WITH 1 INCREMENT BY 1 CACHE 20;
    And then issue :

    Code:
    INSERT INTO TBL1
    SELECT seq1.nextval , 'test', Column3
    FROM TBL1 WHERE Column3='condition';
    HTH & Regards,

    RBARAER

  3. #3
    Join Date
    Feb 2005
    Posts
    9
    Okay thanks, it works.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •