Oracle
 sql >> Datenbank >  >> RDS >> Oracle

xmltype an angegebener Stelle in xmltype einfügen [PL/SQL]

Sie können das erwähnte appendChildXML verwenden , wie hier:

declare
  v_xml  xmltype := xmltype('<ord>
                               <head>
                                 <ord_code>123</ord_code>
                                 <ord_date>01-01-2015</ord_date>
                               </head>
                             </ord>');
  v_xml2 xmltype:= xmltype('<pos>
                              <pos_code>456</pos_code>
                              <pos_desc>description</pos_desc>
                            </pos>');
  v_output xmltype;
begin
  select appendChildXML(v_xml, 'ord', v_xml2) 
    into v_output from dual;

  -- output result
  dbms_output.put_line( substr( v_output.getclobval(), 1, 1000 ) );
end;

Ausgabe:

<ord>
  <head>
    <ord_code>123</ord_code>
    <ord_date>01-01-2015</ord_date>
  </head>
  <pos>
    <pos_code>456</pos_code>
    <pos_desc>description</pos_desc>
  </pos>
</ord>