APEX computation: blob to clob

Импорт файла BLOB с конвертацией в поле CLOB.

P3_IMPORT_FILE — File Browse
Storage Type: Table WWV_FLOW_FILES

P3_CLOB_TXT —  Hidden
Source Type: Database Column

Computations ->
Item Name: P3_CLOB_TXT
Type PL/SQL Function Body
Computation Point: After Submit
Computation:


declare
l_data blob;
l_xml_data clob;
l_clob clob;
l_src_offset integer := 1;
l_dst_offset integer := 1;
l_warn integer;
l_lang_ctx integer := dbms_lob.default_lang_ctx;

begin
if (:P3_IMPORT_FILE is null) then
return l_clob;
end if;
begin
select f.blob_content
into l_data
from wwv_flow_files f
where f.name = P3_IMPORT_FILE;
exception
when no_data_found then
raise_application_error(-20001, apex_lang.message('UPLOAD_FAILED'));
end;
delete from wwv_flow_files where name = P3_IMPORT_FILE;

sys.dbms_lob.createtemporary(l_xml_data, false, sys.dbms_lob.session);
dbms_lob.converttoclob(
l_xml_data,
l_data,
dbms_lob.lobmaxsize,
l_dst_offset,
l_src_offset,
NLS_CHARSET_ID('UTF8'),
l_lang_ctx,
l_warn);

l_clob:= l_xml_data;
sys.dbms_lob.freetemporary(l_xml_data);
P3_IMPORT_FILE := null;
return l_clob;

end;