2017-04-06 123 views
0
OWNER SYS 
DIRECTORY_NAME ME 
DIRECTORY_PATH \\172.16.20.11\Mad\ 


begin 

vSFile := utl_file.fopen('ME','20170405.csv','R'); 
IF utl_file.is_open(vSFile) THEN 
LOOP 

我得到錯誤:PLSQL CSV文件讀取和寫入

ORA-29283: invalid file operation ORA-06512: at "SYS.UTL_FILE", line 536 ORA-29283: invalid file operation ORA-06512: at "MADHUR.MSP_UPD_DAILYSALESFRMSAP", line 28 ORA-06512: at line 1 
29283. 00000 - "invalid file operation" 
*Cause: An attempt was made to read from a file or directory that does 
      not exist, or file or directory access was denied by the 
      operating system. 
*Action: Verify file and directory access privileges on the file system, 
      and if reading, verify that the file exists. 
+0

這是什麼問題?你是否完成了錯誤信息所說的內容? – Aleksej

+0

Oracle是否真的允許(識別)爲[服務器文件系統上的目錄]在Windows的網絡路徑(http://docs.oracle.com/database/121/CNCPT/glossary.htm#CNCPT44466)?你可以將該路徑映射到一個驅動器盤符並查看它是否有效? (也可能是與操作系統權限或Oracle授權的,當然問題...) –

回答

0

之所以獲得這樣的問題是,你沒有readwrite許可權directory

運行下面的查詢,看看是否有readwrite權限的:

SELECT * 
     FROM all_tab_privs 
    WHERE table_name = 'your_directory name';  

如果發現不具有任何訪問然後授予讀寫PRIVS。

SQL>CREATE OR REPLACE DIRECTORY dir1 as '/opt/oracle/'; 

SQL>GRANT READ,WRITE on dir1 to <Required user>; (if you want to give access to particular user) 
OR 
SQL>GRANT READ,WRITE on dir1 to PUBLIC; (if you want to give access to all users then give access to public) 
+0

我已閱讀並寫permision – kumarh

+0

@kumarh。如果你有權限,那麼在任何情況下你都必須得到這個問題。在這裏看到我的帖子與演示:http://stackoverflow.com/questions/42720366/plsql-open-file-in-write-mode/42720486#42720486 – XING

0

你的錯誤告訴你到底是什麼問題:

*Cause: An attempt was made to read from a file or directory that does not exist, or file or directory access was denied by the operating system.

,做些什麼來解決它:

*Action: Verify file and directory access privileges on the file system, and if reading, verify that the file exists.

所以你指定:

DIRECTORY_PATH \\172.16.20.11\Mad\

您是否能夠實際訪問\\172.16.20.11\Mad\與Oracle的用戶?

如果沒有,那麼你需要grant read, write on directory to user並檢查操作系統權限的用戶到該路徑。

還要考慮做一個網絡共享驅動器號,而不是UNC路徑。

+0

我能夠訪問此路徑,我有權限讀寫 – kumarh

+0

作爲哪個用戶你可以訪問它? –

+0

我不知道確切的規則是什麼甲骨文可以或不可以作爲目錄打開,但在Windows中有一個名爲驅動器和URL之間的差異,即使Windows資源管理器可以呈現兩個相同的方式。例如,我可以'dir'\\ ln-sharepoint.blahblah.net \ Root \ whatever \ docs「'或者在資源管理器中瀏覽它,它會顯示爲常規文件夾,但是如果我嘗試對其執行」cd「操作得到'CMD不支持作爲當前目錄的UNC路徑 –