Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

UTL_COMPRESS Zipping Multiple BLOBs

780189Aug 17 2010 — edited Jan 30 2012
Hey everyone, I'm having trouble figuring out how to use UTL_COMPRESS.

What I want to do is take several BLOBs from one table, and put them into one zip file. Can anyone show me an example of where this is done?

Here is some sample code of what I have so far:

My table:
CREATE TABLE  "FILES" 
   (	"FILE_ID" NUMBER, 
	"FILE_TYPE" NUMBER, 
	"FILENAME" VARCHAR2(1000), 
	"DATE_ADDED" DATE, 
	"ADDED_BY" VARCHAR2(255), 
	"FILE_BLOB" BLOB, 
   )
/
Some sample code:
DECLARE

  b_dl_file1 BLOB;
  b_dl_file2 BLOB;
  b_dl_file3 BLOB;

  b_compressed_file BLOB;

BEGIN

select FILE_BLOB
into b_dl_file1
from FILES
where FILE_ID = 64;

select FILE_BLOB
into b_dl_file2
from FILES
where FILE_ID = 65;

select FILE_BLOB
into b_dl_file3
from FILES
where FILE_ID = 66;

b_compressed_file := UTL_COMPRESS.LZ_COMPRESS(b_dl_file1);
END;
So what I've posted works fine, it compresses a single file. What I want is to take all three of those blobs (for example) and add them to one zip file. I've looked into using UTL_COMPRESS.LZ_COMPRESS_ADD, but as far as I can see, that only takes RAW data. Will I have to break my BLOBs into RAW strings and then compress those? Will that even work?

Any help would be appreciated!
This post has been answered by Anton Scheffer on Aug 17 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 27 2012
Added on Aug 17 2010
20 comments
26,555 views