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!

how to split file using utl package in oracle.

user651567May 30 2014 — edited Jun 5 2014

Hi All,

I want ot create multiple file using utl_file.

EArlier i am write itng whole cursor records in one file.

But now the requirement is to split into multiple files when the cursor recrds exceeded 10000.

So the file will become two if it cross 10000 records amnd so on

if a cursor has 30000 records then i hould create 3 files.

Here is how i wrote the simple logic to write the whole records in to one table.

UTL_FILE.PUTF(file1, head);

    utl_file.new_line(file1);

    FOR vcur_torico_fetch IN cur_torico_fetch

    LOOP

      stmt :=''

      ||chr(9)||''

      ||chr(9)||vcur_torico_fetch.Application_classification

      ||chr(9)||''

      ||chr(9)||''

      ||chr(9)||vcur_torico_fetch.MY_COMP_CODE

      ||chr(9)||vcur_torico_fetch.OU_org_code;

    utl_file.PUTF(file1, stmt);

      utl_file.new_line(file1);

    END LOOP;

  utl_file.fclose(file1);

Kindly let me know the logic to achieve this.

Best Regards,

This post has been answered by Karthick2003 on May 30 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 3 2014
Added on May 30 2014
36 comments
14,539 views