以xml格式导出sql语句的结果

时间:2021-02-06 23:35:53

I need to export the result in xml format, here below is the code :

我需要以xml格式导出结果,下面是代码:

DECLARE
      XmlFic  Utl_File.File_Type;
      XmlData CLOB;
      Fin     BOOLEAN := TRUE;
    BEGIN
       XmlData := DBMS_XMLQuery.GetXML ('SELECT * FROM employees');
       XmlFic := Utl_File.FOpen ('C:\TMP\XML', 'TEST.xml', 'W');
       WHILE FIN LOOP
          Utl_File.Put (XmlFic, SUBSTR (XmlData, 1, 32767));
          IF LENGTH (XmlData) > 32767 THEN
             XmlData :=  SUBSTR (XmlData, 32768);
          ELSE
             FIN := FALSE;
          END IF;
       END LOOP;
       Utl_File.FClose (XmlFic);
    EXCEPTION
       WHEN OTHERS THEN
          DBMS_OUTPUT.PUT_LINE (SUBSTR (SQLERRM,1,255));
          Utl_File.FClose (XmlFic);
    END;

I get the following error :

我收到以下错误:

ORA-06550: line 2, column 11: PLS-00201: identifier 'UTL_FILE' MUST BE DECLARED PLS-00201: identifier 'DBMS_XMLQUERY.GETXML' MUST BE DECLARED

ORA-06550:第2行第11列:PLS-00201:标识符'UTL_FILE'必须声明为PLS-00201:标识符'DBMS_XMLQUERY.GETXML'必须声明

Does anyone have an idea what I'm doing wrong? Any help would be much appreciated

有谁知道我做错了什么?任何帮助将非常感激

1 个解决方案

#1


0  

Will it work if you use SYS.DBMS_XMLQUERY instead of only DBMS_XMLQUERY? If that works there is no synonym created (or even the original is deleted).

如果您使用SYS.DBMS_XMLQUERY而不是仅使用DBMS_XMLQUERY,它会工作吗?如果可行,则不会创建同义词(甚至删除原始内容)。

Source: https://forums.oracle.com/thread/2237396

#1


0  

Will it work if you use SYS.DBMS_XMLQUERY instead of only DBMS_XMLQUERY? If that works there is no synonym created (or even the original is deleted).

如果您使用SYS.DBMS_XMLQUERY而不是仅使用DBMS_XMLQUERY,它会工作吗?如果可行,则不会创建同义词(甚至删除原始内容)。

Source: https://forums.oracle.com/thread/2237396