看看这个:
FOPEN FunctionThis function opens a file for input or output. The file location must be an accessible
directory, as defined in the instance’s initialization parameter UTL_FILE_DIR. The
complete directory path must already exist; it is not created by FOPEN.语法:UTL_FILE.FOPEN (
location IN VARCHAR2,
filename IN VARCHAR2,
open_mode IN VARCHAR2)RETURN UTL_FILE.FILE_TYPE;location:
Operating system-specific string that specifies the directory in which to open the file.filename:
Name of the file, including extension (file type), without any directory path nformation. (Under the UNIX operating system, the filename cannot be terminated with a /).open_mode:
String that specifies how the file should be opened (either upper or lower case letters can be used).
The supported values, and the UTL_FILE procedures that can be used with them are:
r read text (GET_LINE)
w write text (PUT, PUT_LINE, NEW_LINE, PUTF, FFLUSH)
a append text (PUT, PUT_LINE, NEW_LINE, PUTF, FFLUSH)
FOPEN FunctionThis function opens a file for input or output. The file location must be an accessible
directory, as defined in the instance’s initialization parameter UTL_FILE_DIR. The
complete directory path must already exist; it is not created by FOPEN.语法:UTL_FILE.FOPEN (
location IN VARCHAR2,
filename IN VARCHAR2,
open_mode IN VARCHAR2)RETURN UTL_FILE.FILE_TYPE;location:
Operating system-specific string that specifies the directory in which to open the file.filename:
Name of the file, including extension (file type), without any directory path nformation. (Under the UNIX operating system, the filename cannot be terminated with a /).open_mode:
String that specifies how the file should be opened (either upper or lower case letters can be used).
The supported values, and the UTL_FILE procedures that can be used with them are:
r read text (GET_LINE)
w write text (PUT, PUT_LINE, NEW_LINE, PUTF, FFLUSH)
a append text (PUT, PUT_LINE, NEW_LINE, PUTF, FFLUSH)
create directory xxx as "c:\xxx\";
然后utl_file.fopen(xxx,'ttt.txt',r);
这样就可以
但是utl_file.fopen('c:\xxx\','ttt.txt',r);
就不行。
who can tell me why.
PL/SQL. The client implementation (text I/O) is subject to normal operating system
file permission checking. However, the server implementation may be running in a
privileged mode, which requires a restriction on the directories that can be accessed.
Accessible directories must be specified in the instance parameter initialization file
(INIT.ORA).Accessible directories for the UTL_FILE functions are specified in the initialization
file using the UTL_FILE_DIR parameter. For example:
UTL_FILE_DIR = <directory name>If the initialization file for the instance contains the line UTL_FILE_DIR =
/usr/jsmith/my_app, then the directory /usr/jsmith/my_app is accessible
to the FOPEN function. Note that a directory named /usr/jsmith/My_App would
not be accessible on case-sensitive operating systems.The parameter specification UTL_FILE_DIR = * should be used with caution. It
turns off directory access checking and makes all directories accessible to the UTL_
FILE functions.