title: Appending to an extracted file
body: <p>I have a procedure that is extracting data from the EDW to a file for another user in Business Objects to use.</p>
  
  <p>I use a cursor to select the data that I need and then run it in a for loop as follows:</p>
  
  <pre><code>FOR x IN c_body LOOP
  
  utl_file.put_line(out_file, x.data_line);
  END LOOP;
  
    utl_file.fclose(out_file);
    DBMS_OUTPUT.PUT_LINE('copy file from ' ||lv_path||'/'||lv_filename|| ' to '                               ||lv_pub_path||'/'||lv_filename);
    OSUTIL.RUNOSCMD('cp -f '||lv_path||'/'||lv_filename||' '||lv_pub_path, lv_os_out, ln_os_num);
  
    IF ln_os_num != 0 THEN
      dbms_output.put_line('copy file '||lv_filename||' failed. error = ' || lv_os_out || ' ' || ln_os_num);
      RAISE exit_now;
    END IF;
  </code></pre>
  
  <p>Is there a way that I can run the procedure multiple times and just append to the extracted file?
  I am currently running a massive extract of 2 years history data and would rather append multiple times with smaller sets rather than use the full 24 months (it's going to take forever).</p>
  
  <p>Thanks for the help in advance</p>