UTL_FILE package

The UTL_FILE package provides a set of routines for reading from and writing to files on the database server file system.

The UTL_FILE system package includes the following system-defined routines and types.

Table 1. System-defined routines available in the UTL_FILE package
Routine name Description
FCLOSE procedure Closes a specified file.
FCLOSE_ALL procedure Closes all open files.
FFLUSH procedure Flushes unwritten data to a file.
FOPEN function Opens a file.
GET_LINE procedure Gets a line from a file.
NEW_LINE procedure Writes an end-of-line character sequence to a file.
PUT procedure Writes a string to a file.
The following list describes all of the named conditions that an application can receive.
Table 2. Named conditions for an application
Condition Name Description
access_denied Access to the file is denied by the operating system.
charsetmismatch A file was opened using FOPEN_NCHAR, but later I/O operations used non-CHAR functions such as PUTF or GET_LINE.
delete_failed Unable to delete file.
file_open File is already open.
internal_error Unhandled internal error in the UTL_FILE system package.
invalid_filehandle File handle does not exist.
invalid_filename A file with the specified name does not exist in the path.
invalid_maxlinesize The MAX_LINESIZE value for FOPEN is invalid. It must be 1 - 32672.
invalid_mode The open_mode argument in FOPEN is invalid.
invalid_offset The ABSOLUTE_OFFSET argument for FSEEK is invalid. It must be greater than 0 and less than the total number of bytes in the file.
invalid_operation File could not be opened or operated on as requested.
invalid_path The specified path does not exist or is not visible to the database.
read_error Unable to read the file.
rename_failed Unable to rename the file.
write_error Unable to write to the file.