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!

Create a Multiple Files using PL-SQL

RaviROct 29 2013 — edited Oct 30 2013

Hi Experts,

I have a table which contains 360 records and want to create multiple files with each file containing 12 records.

I tried to use the below code, however was unsuccessfull..

Please help!!!!

DECLARE

   num      NUMBER             := 1;

   f_file   UTL_FILE.file_type;

   row_sm   NUMBER             := 0.00;

CURSOR c_cur

   IS

      SELECT   customer_key, all_columns_concat

          FROM demo;

c_rec    c_cur%ROWTYPE;

BEGIN

   OPEN c_cur;

   LOOP

      FETCH c_cur

       INTO c_rec;

     EXIT WHEN c_cur%NOTFOUND;

      WHILE num = c_rec.file_num

      LOOP

         f_file := UTL_FILE.fopen ('DM_DIR', 'FILE_' || num, 'w', 3267);

         num := num + 1;

      END LOOP;


      UTL_FILE.put_line (f_file, c_rec.all_columns_concat);

      row_sm := c_rec.sum_row + row_sm;

   END LOOP;


   UTL_FILE.fclose (f_file);

  CLOSE c_cur;

END;

Regards,

RaviR.

This post has been answered by Ramin Hashimzadeh on Oct 30 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 27 2013
Added on Oct 29 2013
17 comments
3,372 views