Write to File:
1. Empowering Users with Database administrators
Create or replace directory path alias as ' path ';
Grant read, write on directory path alias to user;
GRANT EXECUTE on utl_file to user;
2. Call Write File
Declaring variables: V_myfilehandle utl_file. File_type;
Open file: v_myfilehandle: = Utl_file. FOPEN (' Path alias ', ' File name ', ' a '); --a Read and write files
Write to file: Utl_file. Put_Line (V_myfilehandle, ' Hello Again for the Second time! ' || To_char (sysdate, ' mm-dd-yy HH:MI:SS AM '));
OFF: Utl_file. FCLOSE (V_myfilehandle);
Utl_file. FOPEN (location in varchar2, filename in varchar2, Open_mode-varchar2) return file_type;
Location is the path parameter,
FileName is the filename,
Open_mode is open mode, ' R ' is read text, ' W ' is written text, ' A ' is an additional text, parameter is not case-sensitive, if you specify ' A ' but the file does not exist, it will be created with ' W ', ' W ' has the function of covering;
http://blog.csdn.net/cnham/article/details/5927700