The FOPEN function is used to open a file based on user-specified information. The system supports opening up to 50 files simultaneously.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this feature.
Syntax
UTL_FILE.FOPEN (
location IN VARCHAR2,
filename IN VARCHAR2,
open_mode IN VARCHAR2,
max_linesize IN BINARY_INTEGER DEFAULT 1024)
RETURN FILE_TYPE;
Parameters
| Parameter | Description |
|---|---|
| location | The name of the path object where the file to be opened is located. |
| filename | The name of the file to be opened. The filename cannot contain "/". |
| open_mode | The mode in which to open the file. Valid values:
a or ab for open_mode when opening a file that does not exist, the file is created in write mode. |
| max_linesize | The maximum number of bytes per line in the file, including the newline character. The value ranges from [1, 32767]. The default value is 1024. |
Return value
FOPEN returns FILE_TYPE, which is the handle of the opened file. This handle must be passed to all subsequent operations on the file. The content of the file handle is private to UTL_FILE and cannot be referenced or modified.
Exceptions
INVALID_MAXILINESIZEINVALID_MODEINVALID_OPERATIONINVALID_PATHINVALID_FILENAME
Considerations
The file location and filename parameters must be provided to the FOPEN function as quoted strings so that the system can check the file location against the accessible directories specified in the ALL_DIRECTORIES view.
If more than 50 files are opened simultaneously, an INVALID_OPERATION exception is raised.
