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

Home -> Community -> Usenet -> c.d.o.server -> Re: insert statement using order by

Re: insert statement using order by

From: jarichter <jarichter2_at_freezone.co.uk>
Date: Tue, 12 Oct 1999 20:30:57 +0100
Message-ID: <380393d0.0@news1>


Stephen,
unlike the previous reply....I don't care why you want to insert in order...that is your business the easiest way I would see to do it would be with a PL/SQL block or Procedure such as:

DECLARE
commit_counter PLS_INTEGER (3) :=0;

CURSOR get_em IS
SELECT *
FROM othertable
ORDER BY desc;

BEGIN
FOR ins_rows IN get_em
LOOP

            INSERT INTO table_name VALUES (ins_rows.col1, ins_rows.col2);
            IF commit_counter > 500 THEN
                    COMMIT;
                    commit_counter :=0;
            ELSE
                    commit_counter := commit_counter +1;
            END IF;

END LOOP;
END;
/

However, after this you will need to rebuild any indexes on the table because they will be severly unbalanced and thus slow.

Regards,
Jack Received on Tue Oct 12 1999 - 14:30:57 CDT

Original text of this message

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