Utl_File

Description: The Oracle supplied package UTL_FILE can be used to read and write files that are located on the server. It cannot be used to access files locally, that is, on the computer where the client is running.

OPEN a file FOR read operations UTL_FILE.fopen(
file_location IN VARCHAR2,
file_name     IN VARCHAR2,
open_mode     IN VARCHAR2,
max_linesize  IN BINARY_INTEGER DEFAULT NULL)
RETURN file_type;
DECLARE
 vInHandle UTL_FILE.file_type;
 vNewLine  VARCHAR2(250);
BEGIN
  vInHandle := UTL_FILE.fopen('ORATEST', 'test.txt', 'R');
  LOOP
    BEGIN
      UTL_FILE.get_line(vInHandle, vNewLine);
      DBMS_OUTPUT.put_line(vNewLine);
    EXCEPTION
      WHEN OTHERS THEN
        EXIT;
    END;
  END LOOP;
  UTL_FILE.fclose(vInHandle);
END fopen;
/
OPEN A File FOR WRITE Operations <file_handle> := UTL_FILE.fopen(<file_location, file_name, 'W')
 
 
fclose
PROCEDURE fclose (
 file                           IN OUT                   RECORD
);
 
fclose_all
PROCEDURE fclose_all (
);
 
fcopy
PROCEDURE fcopy (
 src_location                       IN                 VARCHAR2        ,
 src_filename                       IN                 VARCHAR2        ,
 dest_location                      IN                 VARCHAR2        ,
 dest_filename                      IN                 VARCHAR2        ,
 start_line                         IN           BINARY_INTEGER DEFAULT,
 end_line                           IN           BINARY_INTEGER DEFAULT
);
 
fflush
PROCEDURE fflush (
 file                               IN                   RECORD
);
 
fgetattr
PROCEDURE fgetattr (
 location                           IN                 VARCHAR2        ,
 filename                           IN                 VARCHAR2        ,
 fexists                           OUT                  BOOLEAN        ,
 file_length                       OUT                   NUMBER        ,
 block_size                        OUT           BINARY_INTEGER
);
 
fgetpos
FUNCTION fgetpos returns BINARY_INTEGER
 (
 file                               IN                   RECORD
);
 
fopen
FUNCTION fopen returns RECORD
 (
 location                           IN                 VARCHAR2        ,
 filename                           IN                 VARCHAR2        ,
 open_mode                          IN                 VARCHAR2        ,
 max_linesize                       IN           BINARY_INTEGER DEFAULT
);

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.