0
XML 형식 데이터를 원시로 변환해야하는 곳에서 작업하고 있지만 가져 오지 않았습니다. XML 데이터를 varchar2로 변환하려고 시도했지만 Cast_to_raw를 사용했지만 16 진수로 원시 변환 오류가 표시됩니다. 친절하게 어떻게하는지 알려주세요.XML 형식 데이터를 원시 형식 데이터로 변환하는 방법
XML 형식 데이터를 원시로 변환해야하는 곳에서 작업하고 있지만 가져 오지 않았습니다. XML 데이터를 varchar2로 변환하려고 시도했지만 Cast_to_raw를 사용했지만 16 진수로 원시 변환 오류가 표시됩니다. 친절하게 어떻게하는지 알려주세요.XML 형식 데이터를 원시 형식 데이터로 변환하는 방법
예에서는 xmltype에서 blob 요소로의 변환을 설명합니다. 원시 값을 얻어야하는 경우 dbms_substr을 수행하십시오.
declare
dest_offset integer;
src_offset integer;
lang_context integer;
warning varchar2(1000);
v_xml_object xmltype;
v_blob blob;
v_clob clob;
begin
--get example xmltype
select dbms_xmlgen.getXmlType('select * from user_objects where rownum < 10') into v_xml_object from dual;
--convert xmltype to clob
v_clob := v_xml_object.getClobVal();
--initi variable
dbms_lob.createtemporary(v_blob, FALSE);
dest_offset := 1;
src_offset := 1;
lang_context := 0;
-- convert to a BLOB here:
dbms_lob.converttoblob(v_blob, v_clob, dbms_lob.getlength(v_clob), dest_offset, src_offset, 0, lang_context, warning);
dbms_output.put_line(warning);
dbms_output.put_line(dbms_lob.substr(v_blob,length(v_blob)));
end;