Oracle
 sql >> Base de Dados >  >> RDS >> Oracle

Como escrever XML para arquivo (PL/SQL)?


1) Config (Log como usuário com CREATE ANY DIRECTORY privilégios)
create or replace directory YOUR_DIR_NAME as '/path/../';
grant read, write on directory YOUR_DIR_NAME to your_schema;

2) Converta xml para clob e salve-o.
declare
  v_xml_clob   clob;
begin
  select xmlserialize(document xmlelement("a", 'lalal') as clob) into v_xml_clob from dual;
  Dbms_xslprocessor.CLOB2FILE(cl => x_xml_clob, flocation => 'YOUR_DIR_NAME', fname => 'somename.xml');
end;