While trying to write a file using utl_file package in PL/SQL, I kept getting the “Directory not found” error about an existing directory. A simple search on the internet shows that a DIRECTORY object should be created for the directory before utl_file package can use it.
CREATE DIRECTORY tempdir AS ‘/the/directory/object/’;
BUT, still there is something to be done which is to set your utl_file_dir parameter. The parameter cannot be altered in the session, a server restart is required.
ALTER SYSTEM SET utl_file_dir=’/the/directory’ SCOPE=spfile;
I found out on the internet that this change was required for Oracle 9i only but I can’t get utl_file working without it on Oracle 11g as well (off course on RHEL 5).