The FOPEN function opens a file based on user-specified information. The system allows you to open up to 50 files at a time.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.
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 path of the file to open. |
| filename | The name of the file to open. The file name cannot contain forward slashes (/). |
| open_mode | The mode in which the file is opened. Valid values:
open_mode to a or ab when you attempt to open a file but the file does not exist, the file is created in write mode. |
| max_linesize | The maximum number of bytes per line in the file, including line breaks. Value range: [1,32767]. The default value is 1024. |
Return values
FOPEN returns FILE_TYPE, which indicates the file handle. The file handle must be passed to all subsequent operations on the file. The content of the file handle is private to the UTL_FILE package and therefore cannot be referenced or modified.
Exceptions
INVALID_MAXILINESIZEINVALID_MODEINVALID_OPERATIONINVALID_PATHINVALID_FILENAME
Considerations
The file location and file name must be passed to the FOPEN function as quoted strings. This way, the function can check the file location based on the list of accessible directories specified in the ALL_DIRECTORIES view.
When more than 50 files are opened at a time, the INVALID_OPERATION exception is thrown.