Oracle 从xml文件中插入具有xmltype列的表

Oracle 从xml文件中插入具有xmltype列的表,oracle,insert,oracle11g,xmltype,Oracle,Insert,Oracle11g,Xmltype,下面是我对插入xml文件的查询 INSERT INTO sampletagtable VALUES ( 1 , XMLType(bfilename('xmldir3', 'book.xml') , nls_charset_id('AL32UTF8') )); 在此之前,我通过以下查询创建了xmldir3 CREATE OR REPLACE DIRECTORY xmldir3 AS '/opt/user/nishanth/xmldir'; 这里/opt/user/nishanth是我的linu

下面是我对插入xml文件的查询

INSERT INTO sampletagtable VALUES ( 1 , XMLType(bfilename('xmldir3', 'book.xml') , nls_charset_id('AL32UTF8') ));
在此之前,我通过以下查询创建了xmldir3

CREATE OR REPLACE DIRECTORY xmldir3 AS '/opt/user/nishanth/xmldir';
这里
/opt/user/nishanth
是我的linux操作系统中的一个目录

book.xml位于指定的目录中

我得到以下错误

SQL Error: ORA-22285: non-existent directory or file for FILEOPEN operation
ORA-06512: at "SYS.XMLTYPE", line 296
ORA-06512: at line 1
22285. 00000 -  "non-existent directory or file for %s operation"
*Cause:    Attempted to access a directory that does not exist, or attempted
           to access a file in a directory that does not exist.
*Action:   Ensure that a system object corresponding to the specified
           directory exists in the database dictionary, or
           make sure the name is correct.

您将目录创建为
xmldir3
,它是一个不带引号的标识符,因此在数据字典中是大写的。但你可以用小写字母来表示。您需要使用:

bfilename('XMLDIR3', 'book.xml')
您可以通过查询
所有\u目录
视图来检查实际目录名:

SQL> CREATE OR REPLACE DIRECTORY xmldir3 AS '/opt/user/nishanth/xmldir';

Directory created.

SQL> SELECT directory_name, directory_path FROM all_directories;

DIRECTORY_NAME                 DIRECTORY_PATH
------------------------------ ----------------------------------------
XMLDIR3                        /opt/user/nishanth/xmldir
...