2014-05-09 65 views
0

以下插入到表XMLType列是我的查詢插入XML文件從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. 

回答

1

您創建的目錄爲xmldir3,這是一個帶引號的標識符因此這將是大寫的數據字典。但是,你可以用小寫來表示它。您需要使用:

bfilename('XMLDIR3', 'book.xml') 

您可以通過查詢all_directories視圖檢查實際的目錄名稱:

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 
... 
+0

它的工作原理,謝謝:)。 –