2017-05-15 194 views

回答

0

示例描述了從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; 
相關問題