Tag Archives: UTL

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]