SQLPlus - spooling to multiple files from PL/SQL blocks

后端 未结 6 1048
说谎
说谎 2020-12-17 04:06

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

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-17 04:53

    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.

提交回复
热议问题