title: SQLPlus - spooling to multiple files from PL/SQL blocks
body: <p>I have a query that returns a lot of data into a CSV file. So much, in fact, that Excel can't open it - there are too many rows. Is there a way to control <code>spool</code> to spool to a new file everytime 65000 rows have been processed? Ideally, I'd like to have my output in files named in sequence, such as <code>large_data_1.csv</code>, <code>large_data_2.csv</code>, <code>large_data_3.csv</code>, etc...</p>
  
  <p>I could use <code>dbms_output</code> in a PL/SQL block to control how many rows are output, but then how would I switch files, as <code>spool</code> does not seem to be accessible from PL/SQL blocks?</p>
  
  <p>(Oracle 10g)</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I don't have access to the server, so writing files to the server would probably not work.</p>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>Some of the fields contain free-form text, including linebreaks, so counting line breaks AFTER the file is written is not as easy as counting records WHILE the data is being returned...</p>