Re: insert statement using order by

From: Bob Fazio <bob_fazio_at_hotmail.com.no.spam>
Date: 1999/10/13
Message-ID: <LCZM3.807$yp.5219_at_news.rdc1.pa.home.com>#1/1


The point isn't how to do it!!

The point is no matter if you do or don't insert in a sorted order Oracle won't guarentee that it will store it that way. So when you select you may get another order.

It will most often work that if you insert in a certain order, Oracle will store it that way. But it can't
be counted on. So don't bother expecting that it will work.

jarichter <jarichter2_at_freezone.co.uk> wrote in message news:380393d0.0_at_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 Wed Oct 13 1999 - 00:00:00 CEST

Original text of this message