Ir para o conteúdo principal

Função - Converter CLOB para BLOB

SQL: 

create or replace function clob_to_blob(l_clob clob) return blob is
  l_blob         blob;
  l_dest_offset  number := 1;
  l_src_offset   number := 1;
  l_lang_context number := dbms_lob.default_lang_ctx;
  l_warning      number;
begin
  dbms_lob.createtemporary(l_blob, true);
  dbms_lob.converttoblob(dest_lob     => l_blob,
                         src_clob     => l_clob,
                         amount       => dbms_lob.lobmaxsize,
                         dest_offset  => l_dest_offset,
                         src_offset   => l_src_offset,
                         blob_csid    => nls_charset_id('al32utf8'),
                         lang_context => l_lang_context,
                         warning      => l_warning);
  return l_blob;
end clob_to_blob;

Chamada da função:

select clob_to_blob('Teste') from dual

Retorno:

(BLOB)