wood burning stoves 2.0*
The moose likes Oracle/OAS and the fly likes Getting error while reading file by using UTL_FILE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "Getting error while reading file by using UTL_FILE" Watch "Getting error while reading file by using UTL_FILE" New topic
Author

Getting error while reading file by using UTL_FILE

srikanth sankurthi
Greenhorn

Joined: Oct 09, 2012
Posts: 9
DECLARE
fileID UTL_FILE.FILE_TYPE;
strbuffer VARCHAR2(100);
firstTen VARCHAR2(10);
BEGIN
fileID := UTL_FILE.FOPEN ('D:\srikanth.txt', 'srikanth.txt', 'R');
UTL_FILE.GET_LINE (fileID, strbuffer);
UTL_FILE.FCLOSE(fileID);
END;

Gives the following error.
=================

Error starting at line 25 in command:
DECLARE
fileID UTL_FILE.FILE_TYPE;
strbuffer VARCHAR2(100);
firstTen VARCHAR2(10);
BEGIN
fileID := UTL_FILE.FOPEN ('D:\srikanth.txt', 'srikanth.txt', 'R');
UTL_FILE.GET_LINE (fileID, strbuffer);
UTL_FILE.FCLOSE(fileID);
END;
Error report:
ORA-29280: invalid directory path
ORA-06512: at "SYS.UTL_FILE", line 29
ORA-06512: at "SYS.UTL_FILE", line 448
ORA-06512: at line 6
29280. 00000 - "invalid directory path"
*Cause: A corresponding directory object does not exist.
*Action: Correct the directory object parameter, or create a corresponding
directory object with the CREATE DIRECTORY command.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3606
    
  60

To access a directory in PL/SQL, you need to create a named directory object. It is done using CREATE DIRECTORY command, which is also hinted in your error message. Oracle then allows admin to grant permissions on this object, which is how access to directories can be secured in Oracle. The first parameter of the UTL_FILE.FOPEN function must be the name of the directory object.

Have a look at the documentation of the CREATE DIRECTORY command and UTL_FILE.FOPEN function. Feel free to ask again if anything is unclear.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting error while reading file by using UTL_FILE
 
Similar Threads
Error in Oracle like clause
Read File in PL/SQL
PL / SQL to create synonyms for all tables
Read a text file in Unix
Large data file read