• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Getting error while reading file by using UTL_FILE

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic