Função - Converter BLOB para CLOB
SQL:
create or replace function blob_to_clob (b in blob) return clob is
pos pls_integer := 1;
buffer varchar2( 32767 );
res clob;
lob_len pls_integer := dbms_lob.getlength( b );
begin
dbms_lob.createtemporary( res, true );
dbms_lob.open( res, dbms_lob.lob_readwrite );
loop
buffer := utl_raw.cast_to_varchar2( dbms_lob.substr( b, 16000, pos ) );
if length( buffer ) > 0 then
dbms_lob.writeappend( res, length( buffer ), buffer );
end if;
pos := pos + 16000;
exit when pos > lob_len;
end loop;
return res;
end blob_to_clob;
Chamada da função:
select blob_to_clob(utl_raw.cast_to_raw('Valor Blob')) from dual
Retorno:
Valor Blob