Many types of programs that access databases are also required to reach out into the operating system for external data. A typical example of this is a PL/SQL program that loads data into a table from an external flat file. This program reads and processes each line in the file, then inserts that data into the table. In this section, we will examine Oracle's recommended method for accessing external files from a database—the directory object.
For many years, the primary method of performing operations that require operating system access was to use the Oracle-supplied UTL_FILE
PL/SQL package. UTL_FILE
could be used to read from and write to files. Access to the various OS directories was specified using the parameter, UTL_FILE_DIR
. Thus if UTL_FILE_DIR
was set to /home/oracle
or E:\app\oracle
, a program with the "execute" permission on UTL_FILE
could read and write files in that directory. Thus, assigning directory values to the...