UTL_FILE Sample Code

Here is some sample code using the UTL_FILE package:

DECLARE
  string1 VARCHAR2(32767);
  file1 UTL_FILE.FILE_TYPE;
BEGIN
--  file1 := UTL_FILE.FOPEN('TEMP_DIR','log_file_test','A'); -- open in append mode
  file1 := UTL_FILE.FOPEN('/usr/tmp','log_file_test','A'); -- open in append mode
  string1 := TO_CHAR(SYSDATE) || ' UTL_FILE test';
  UTL_FILE.PUT_LINE(file1, string1); -- write a string to the file
  UTL_FILE.FFLUSH(file1);
  UTL_FILE.FCLOSE_ALL; -- close all open files
END;
/

[amazon asin=0596514468&template=iframe image&chan=default]    [amazon asin=0137142838&template=iframe image&chan=default]    [amazon asin=0071614214&template=iframe image&chan=default]

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


This site uses Akismet to reduce spam. Learn how your comment data is processed.