向oracle中插入xml问题。版本oracle9.2.0.1.0
建立XMLType类型表,和插入记录步骤如下:
---------------------------------------------
CREATE TABLE XMLTABLE OF XMLType;create or replace function getDocument(filename varchar2) return clob
authid current_user is
xbfile bfile;
xclob clob;
begin
xbfile := bfilename('XMLDIR',filename);
dbms_lob.open(xbfile);
dbms_lob.createtemporary(xclob,TRUE,dbms_lob.session);
dbms_lob.loadfromfile(xclob,xbfile, dbms_lob.getlength(xbfile));
dbms_lob.close(xbfile);
return xclob;
end;
/
-- create XMLDIR directory
-- connect system/manager
-- create directory XMLDIR as '<location_of_xmlfiles_on_server>';
-- grant read on directory xmldir to public with grant option;
-- you can use getDocument() to generate a CLOB from a file containing an XML
-- document. For example, the following statement inserts a row into the
-- XMLType table Example2 created earlier:
INSERT INTO XMLTABLE
VALUES(XMLTYPE(getDocument('purchaseorder.xml')));
-----------------------------------------------------------oracle提示如下错误:
VALUES(XMLTYPE(getDocument('purchaseorder.xml')))
       *
ERROR 位于第 2 行:
ORA-31011: XML 语言分析失败
ORA-19202: XML 处理
LPX-00210: expected '<' instead of '<'
Error at line 1
时出错
ORA-06512: 在"SYS.XMLTYPE", line 0
ORA-06512: 在line 1我的xml文件没有任何问题,况且我还试了oracle自带的一些xml文档。