我正在尝试使用以下代码使用 PL/SQL 过程制作 XML 文件:-
create or replace directory temp_dir as 'C:\XML';
grant read, write on directory temp_dir to hr;
DECLARE
doc DBMS_XMLDOM.DOMDocument;
xdata XMLTYPE;
CURSOR xmlcur IS
SELECT xmlelement("Employee",XMLAttributes('http://www.w3.org/2001/XMLSchema' AS "xmlns:xsi",
'http://www.oracle.com/Employee.xsd' AS "xsi:nonamespaceSchemaLocation")
,xmlelement("EmployeeNumber",e.employee_id)
,xmlelement("EmployeeName",e.first_name)
,xmlelement("Department",xmlelement("DepartmentName",d.department_name)
,xmlelement("Location",d.location_id)
)
)
FROM employees e
,departments d
WHERE e.department_id=d.department_id;
BEGIN
OPEN xmlcur;
FETCH xmlcur INTO xdata;
CLOSE xmlcur;
doc := DBMS_XMLDOM.NewDOMDocument(xdata);
DBMS_XMLDOM.WRITETOFILE(doc, 'temp_dir/myXML1.xml');
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20002,'Error writing out XML.');
END;
但我收到以下错误:-
Line 185: ORA-29280: invalid directory path
ORA-06512: at "SYS.UTL_FILE", line 41
ORA-06512: at "SYS.UTL_FILE", line 478
ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 217
ORA-29280: invalid directory path
ORA-29280: invalid directory path
ORA-06512: at "XDB.DBMS_XMLDOM", line 5292
ORA-06512: at line 23
我做错了什么。