What is The Maximum Number of Files That Can Be Opened Using UTL_FILE.FOPEN() ?
CAUSE
The maximum number of concurrent files that can be opened by fopen is 50 files.
This function opens a file. You can specify the maximum line size and have a maximum of 50 files open simultaneously. See also FOPEN_NCHAR Function.
SOLUTION
Work around:
------------------
If the maximum open files are being hit, in the emergency cases only;
add the command "UTL_FILE.FCLOSE_ALL;" after the fclose.
Example:
IF UTL_FILE.IS_OPEN ( in_file_id) THEN
UTL_FILE.FCLOSE (in_file_id);
UTL_FILE.FCLOSE_ALL;
END IF;
FCLOSE_ALL Procedure
This procedure closes all open file handles for the session. This should be used as an emergency cleanup procedure, for example, when a PL/SQL program exits on an exception.
Syntax
UTL_FILE.FCLOSE_ALL;
Note:
FCLOSE_ALL does not alter the state of the open file handles held by the user. This means that an IS_OPEN test on a file handle after an FCLOSE_ALL call still returns TRUE, even though the file has been closed. No further read or write operations can be performed on a file that was open before an FCLOSE_ALL.
Exceptions
WRITE_ERROR
CAUSE
The maximum number of concurrent files that can be opened by fopen is 50 files.
This function opens a file. You can specify the maximum line size and have a maximum of 50 files open simultaneously. See also FOPEN_NCHAR Function.
SOLUTION
Work around:
------------------
If the maximum open files are being hit, in the emergency cases only;
add the command "UTL_FILE.FCLOSE_ALL;" after the fclose.
Example:
IF UTL_FILE.IS_OPEN ( in_file_id) THEN
UTL_FILE.FCLOSE (in_file_id);
UTL_FILE.FCLOSE_ALL;
END IF;
FCLOSE_ALL Procedure
This procedure closes all open file handles for the session. This should be used as an emergency cleanup procedure, for example, when a PL/SQL program exits on an exception.
Syntax
UTL_FILE.FCLOSE_ALL;
Note:
FCLOSE_ALL does not alter the state of the open file handles held by the user. This means that an IS_OPEN test on a file handle after an FCLOSE_ALL call still returns TRUE, even though the file has been closed. No further read or write operations can be performed on a file that was open before an FCLOSE_ALL.
Exceptions
WRITE_ERROR