Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Oracle PL/SQL: UTL_FILE Jump to:  
Category: >> Oracle PL/SQL >> UTL_FILE Bookmark and Share

<< lastnext >>

Snippet Name: 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.

Also see:
» UTL_FILE file write to file example
» UTL_FILE import data

Comment: (none)

Language: PL/SQL
Highlight Mode: PLSQL
Last Modified: March 07th, 2009

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
);
 


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 273 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?