I need to generate a XML and write it to a file. I have used utl_file.put_line. It creates the file, but nothing is written into it. Also, it shows no errors. I've already checked if I have the permissions to write on the directory. Code:
SET serveroutput ON;
DECLARE
ctx DBMS_XMLGEN.CTXHANDLE;
resposta CLOB;
xml_file utl_file.file_type;
BEGIN
xml_file:=utl_file.fopen ('DATA_PUMP_DIR', 'xml.txt', 'W');
ctx := dbms_xmlgen.newContext ('select * from tb_museu M where M.cnpj=111111 OR M.cnpj=222222');
dbms_xmlgen.setRowsetTag (ctx, 'TODOS_OS_MUSEUS');
dbms_xmlgen.setRowTag (ctx, 'MUSEU');
resposta :=dbms_xmlgen.getXML (ctx);
utl_file.put_line (xml_file,'teste');
--utl_file.put_line (xml_file,resposta);
dbms_xmlgen.closeContext(ctx);
END;
/