UTL_FILE Enhancements
Oracle9i Release 2 includes some long overdue enhancements to theUTL_FILE package including basic file handling
and support for NCHAR and RAW data.The basic file handling is summarised below:
SET SERVEROUTPUT ON
DECLARE
v_exists BOOLEAN;
v_file_length NUMBER;
v_block_size NUMBER;
BEGIN
UTL_FILE.FRENAME (src_location => 'c:\',
src_filename => 'test.txt',
dest_location => 'c:\',
dest_filename => 'test1.txt',
overwrite => TRUE);
UTL_FILE.FCOPY(src_location => 'c:\',
src_filename => 'test1.txt',
dest_location => 'c:\',
dest_filename => 'test2.txt');
UTL_FILE.FREMOVE(location => 'c:\',
filename => 'test2.txt');
UTL_FILE.FGETATTR(LOCATION => 'c:\',
FILENAME => 'test1.txt',
FEXISTS => v_exists,
FILE_LENGTH => v_file_length,
BLOCK_SIZE => v_block_size);
IF v_exists THEN
DBMS_OUTPUT.PUT_LINE('Exists: TRUE');
ELSE
DBMS_OUTPUT.PUT_LINE('Exists: FALSE');
END IF;
DBMS_OUTPUT.PUT_LINE('File Length:' || v_file_length);
DBMS_OUTPUT.PUT_LINE('Block Size :' || v_block_size);
END;
/
Support for NCHAR and RAW data has been included with the following procedures:- FOPEN_NCHAR
- GET_LINE_NCHAR
- PUT_LINE_NCHAR
- PUT_NCHAR
- PUTF_NCHAR
- GET_RAW
- PUT_RAW
GET_% procedures now include a LEN parameter which specifies the number of characters to read. To
support this functionality the FGETPOS function allows you to read the current pointer position, while the FSEEK
procedure allow you to set it.For further information see Oracle9i Supplied PL/SQL Packages and Types Reference.
Hope this helps. Regards Tim...
Back to the Top.
