FUNCTION blob_to_clob(blob_in IN BLOB) RETURN CLOB AS
v_clob CLOB;
v_varchar VARCHAR2(32767 );
v_start PLS_INTEGER := 1 ;
v_buffer PLS_INTEGER := 32767 ;
tmp_num NUMBER;
BEGIN
dbms_lob.createtemporary(v_clob, TRUE);
tmp_num := ceil(dbms_lob.getlength(blob_in) / v_buffer);
IF tmp_num
> 0 THEN
--防止传入的BLOB为NULL或长度为0时引发错误
FOR i IN 1 ..
tmp_num LOOP
v_varchar := utl_raw.cast_to_varchar2(dbms_lob.substr(blob_in,
v_buffer,
v_start));
dbms_lob.writeappend(v_clob, length(v_varchar), v_varchar);
v_start := v_start + v_buffer;
END LOOP ;
END IF ;
RETURN v_clob;
END blob_to_clob;
3、将clob数据插入文件中
dbms_xslprocessor.clob2file(l_clob, p_dir_name, p_file_name);