2

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

Kresten
  • 810
  • 13
  • 36

1 Answers1

2

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'); 
Derviş Kayımbaşıoğlu
  • 28,492
  • 4
  • 50
  • 72