Here is my solution for joining any number of BLOBs into single BLOB using helper table type and stored function:
create or replace type blobs as table of blob;
create or replace function concat_blobs(parts in blobs) return blob
is
temp blob;
begin
if parts is null or parts.count = 0 then
return null;
end if;
dbms_lob.createtemporary(temp, false, dbms_lob.CALL);
for i in parts.first .. parts.last
loop
dbms_lob.append(temp, parts(i));
end loop;
return temp;
end;
-- usage example:
select concat_blobs(blobs(to_blob(hextoraw('CAFE')), to_blob(hextoraw('BABE')))) from dual;
-- bonus
create or replace type raws as table of raw(2000);
create or replace function raws_to_blobs(arg in raws) return blobs
is
res blobs;
begin
select to_blob(column_value) bulk collect into res from table(arg);
return res;
end;
-- usage example:
select concat_blobs(raws_to_blobs(raws(hextoraw('CAFE'), hextoraw('BABE'))) from dual;
See also multiple RAWs concatenation in Oracle 10: Using HEXTORAW to fill in blob data.