Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: insert statement using order by
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;
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
![]() |
![]() |