Oracle PL/SQL: Getting UTL_FILE working

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).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s