Reply your question
Giordano Babolin, August 22, 2017 - 10:25 am UTC
Thanks for your answer.
My problem is I don't have a permission to write a file so I need to this by a temporary table.
My goal is to create a zip file to future user download directly from application
August 22, 2017 - 10:47 am UTC
If you want to allow people to download your data, offer this functionality in your UI code.
Creating it using PL/SQL and storing in a database table is a crazy way to do this!
Possible, but maybe not really the best way?
Kim Berg Hansen, August 22, 2017 - 11:00 am UTC
@Giordano,
I'm in general an advocate of doing as much data work in the database as possible.
Creating a zip file of the data for download, however, is something I personally would do on the web-server rather than the database. Either on-the-fly when the download is requested, or (if that is too slow) have the web-server periodically read the data and create the zip-file as a kind of "cache".
But if for example it's an APEX or mod_plsql application with a web-server that's basically just a proxy without any functionality or file services, then it could possibly be needed to do it in the database. If so, then it should be possible along these lines:
1) Build the CSV manually in a CLOB.
2) DBMS_LOB.CONVERTTOBLOB to get a BLOB.
3) UTL_COMPRESS.LZ_COMPRESS to zip the BLOB into another BLOB.
4) Store the resultant BLOB in a table.
But I suggest only to try it if really necessary. The most logical place for this functionality (in my opinion) is the web-server.
Cheerio
/Kim
August 22, 2017 - 12:52 pm UTC
Indeed. Zipping results for download isn't really something you should do in the DB.