Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

INSERT INTO...... SELECT or CURSOR

simon87Jan 13 2015 — edited Jan 15 2015

Hi,


Considering that I have millions of records, what is the best option?


>>>Retrieval on a cursor and scan the cursor with a LOOP Ejemp:


CURSOR itm_cur IS

  SELECT atribute

  FROM   table;


    LOOP

       FETCH itm_cur BULK COLLECT

       INTO lcur_itm_cur /*itm_tbl */LIMIT 1000;

   

       IF lcur_itm_cur.COUNT =0 THEN

         GOTO exit_itm_cur;

       END IF;

       ............................................................................................

      <<exit_itm_cur>>

      EXIT WHEN itm_cur%NOTFOUND;

   

    COMMIT;

  END LOOP;

  CLOSE itm_cur;

OR

>>>  INSERT INTO TABLE1 

        SELECT *FROM TABLE2

 

Thank you

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 12 2015
Added on Jan 13 2015
8 comments
2,171 views