95 UTL_FILE → With the UTL_FILE package, your PL/SQL programs can read and write operating system text files … . UTL_FILE provides a restricted version of operating system stream file I/O. UTL_FILE I/O capabilities … , you call FCLOSE to complete any output and free resources associated with the file. Note: The UTL_FILE … Builder.
About the UTL_FILE Package → Package UTL_FILE allows your PL/SQL programs to read and write operating system (OS) text files. It
Summary of UTL_FILE Subprograms → Table 95-2 UTL_FILE Subprograms Subprogram Description FOPEN Function Opens a file for input or
Using the UTL_FILE Package with NCHAR Data → The UTL_FILE package has been enhanced in Oracle9 i to handle Unicode national character set data … of in the database character set. See Also: Oracle9i Supplied PL/SQL Packages and Types Reference for more information about the UTL_FILE package
Exceptions → None. FCLOSE Procedure This procedure closes an open file identified by a file handle. If there is buffered data yet to be written when FCLOSE runs, then you may receive a WRITE_ERROR exception when closing a file.
Exceptions → WRITE_ERROR INVALID_FILEHANDLE
Syntax → UTL_FILE.FCLOSE_ALL;
GET_LINE_NCHAR Procedure → This procedure reads text from the open file identified by the file handle and places the text in the output buffer parameter. With this function, you can read a text file in Unicode instead of in the database charset. See also \"GET_LINE Procedure\".
PUT_RAW Function → This function accepts as input a RAW data value and writes the value to the output buffer. You can request an automatic flush of the buffer by setting the third argument to TRUE. The maximum size of the buffer parameter is 32767 bytes unless you specify a smaller size in FOPEN. The default is approximately 1000 bytes, depending on your platform. The sum of all sequential PUT calls cannot exceed 32767
Syntax → UTL_FILE.NEW_LINE ( file IN FILE_TYPE, lines IN NATURAL:= 1);
Parameters → Table 95-14 NEW_LINE Procedure Parameters Parameters Description file Active file handle returned by an FOPEN or FOPEN_NCHAR call. lines Number of line terminators to be written to the file.
Parameters → Table 95-16 PUT_LINE_NCHAR Procedure Parameters Parameters Description file Active file handle returned by an FOPEN_NCHAR call. The file must be open for reading (mode r ). If the file is opened by FOPEN instead of FOPEN_NCHAR, a CHARSETMISMATCH exception is raised. buffer Text buffer that contains the lines to be written to the file.
Exceptions → INVALID_FILEHANDLE INVALID_OPERATION WRITE_ERROR
FSEEK Function → This function adjusts the file pointer forward or backward within the file by the number of bytes specified. If offset, the function seeks to a byte offset. If the end of the file or the beginning of the file is reached before seeking is done, the function returns the last or first row, respectively. If loc, the function seeks to an absolute location specified in bytes.
Syntax → UTL_FILE.FSEEK ( fid IN utl_file.file_type, absolute_offset IN PL_INTEGER DEFAULT NULL, relative_offset IN PLS_INTEGER DEFAULT NULL);
FCOPY Function → This function copies a contiguous portion of a file to a newly created file. By default, the whole file is copied if the start_line and end_line parameters are omitted. The source file is opened in read mode. The destination file is opened in write mode. A starting and ending line number can optionally be specified to select a portion from the center of the source file for copying.
Syntax → UTL_FILE.FGETATTR( location IN VARCHAR2, filename IN VARCHAR2, exists OUT BOOLEAN, file_length OUT NUMBER, blocksize OUT NUMBER);
Security → UTL_FILE is available for both client-side and server-side PL/SQL. The client implementation (text … can access. In the past, accessible directories for the UTL_FILE functions were specified in the … objects offer more flexibility and granular control to the UTL_FILE application administrator, can be
Syntax → UTL_FILE.FOPEN_NCHAR ( location IN VARCHAR2, filename IN VARCHAR2, open_mode IN VARCHAR2, max_linesize IN BINARY_INTEGER) RETURN file_type;