My Oracle Support Banner

UTL_FILE Does Not Create a File and No Errors Are Returned (Doc ID 1063852.1)

Last updated on JULY 05, 2017

Applies to:

PL/SQL - Version: - Release: 10.2
Information in this document applies to any platform.


Using a very simple code-block to test the UTL_FILE package to make sure it creates a file properly in the desired directory on the Database server. The script runs successfully but there is no file in the directory.

SQL> create directory TEST_DIR1 as '/tmp';

set serveroutput on

   l_file_handle utl_file.file_type;
   l_file_name varchar2(20) := 'Output.txt';
   l_dir_name varchar2(50) := 'TEST_DIR1';
   l_FILE_HANDLE := utl_file.fopen(l_DIR_NAME,l_FILE_NAME,'W');
   IF utl_file.is_open(l_FILE_HANDLE) THEN
      dbms_output.put_line ('File is open');
   END IF;
   utl_file.put_line(l_FILE_HANDLE, 'Hello World');


To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.