title: Inserting million of records into a file
body: <p>I want to insert million of records into a file using oracle and without using a loop or java code.</p>
  
  <p>while browsing I found something as util_file in oracle which is used to record rows into file but was unable to use it. can some please help me in understanding or writing the code to write the resultset returned by a select query into a file or even a procedure would even work.</p>
  
  <p>I tried below procedure it run successfully but doesnot create file with data</p>
  
  <pre><code>  create or replace procedure familydetails 
         ( p_file_dir IN varchar2, p_filename IN varchar2 ) 
        IS v_filehandle utl_file.file_type; 
         cursor family Is  
         select * from fmly_detl  
         begin 
         v_filehandle :=utl_file.fopen('C:\tempfolder','sqltest.txt','W'); 
         utl_file.new_line(v_filehandle); 
         for fmly IN fmly_detl LOOP 
         utl_file.putf(v_filehandle,'family %s details:s\n',fmly.last_name,fmly.first_name,fmly.indv_id);   
         end loop;
        utl_file.put_line(v_filehandle,'END OF REPORT'); 
         UTL_FILE.fclose(v_filehandle); 
         end familydetails;
  </code></pre>