简体   繁体   中英

Where can I access a file from my oracle db with UTL_FILE?

I'm trying to read from a file with oracle db using UTL_FILE. I can't find a file location I have access to. Whenever I use this code:

DECLARE 
  F1 UTL_FILE.FILE_TYPE; 
BEGIN 
  F1 :=UTL_FILE.FOPEN('C:\TEMP','test_file.txt','R'); 
END;

I get: ORA-29280: invalid directory path

Why would that be?

Can I somehow make oracle show the location I have access to?

BR Kresten

UTL_FILE.FOPEN uses DBA_DIRECTORIES .

SELECT * from ALL_DIRECTORIES 

gives you defined and accessible DBA_DIRECTORIES .

You can create directory for your File operations

CREATE DIRECTORY File_Op_Dir AS '/u01/fileDir';
GRANT READ ON DIRECTORY File_Op_Dir TO <<user>>;
--IF you need write permission 
GRANT WRITE ON DIRECTORY File_Op_Dir TO <<user>>; 

Then

 F1 := UTL_FILE.FOPEN('File_Op_Dir','u12345.tmp','R'); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM