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 spool
utl_file is the package you are looking for. You can write a cursor and loop over the rows (writing them out) and when mod(num_rows_written,num_per_file) == 0 it's time to start a new file. It works fine within PL/SQL blocks.
Here's the reference for utl_file:
http://www.adp-gmbh.ch/ora/plsql/utl_file.html
NOTE: I'm assuming here, that it's ok to write the files out to the server.