I have a procedure which creates a file with as many records returned from a cursor as possible. Due to downstream file size issues, I want to limit each file to ~500k(n) records (value to derive from a parameter table). If there are more than 500k(n) records in the cursor, a new file with a newer timestamp should be created. The procedure uses the following steps.
set v_date = to_char(SYSDATE, 'YYYYMMDDHH24MISS');
set new_file_name = 'new_file_'|| v_date
open record cursor
loop
fetch bulk collect with 1000 record limit
for loop
write records to file
end loop
clear cache
close cursor loop
Before down-voting, please leave a comment if you need more information. I am looking for the easiest solution as well as the most efficient solution.