Show file content : File Read with UTL_FILE « System Packages « Oracle PL/SQL Tutorial






SQL>
SQL> CREATE OR REPLACE PROCEDURE show_file (loc IN VARCHAR2,file IN VARCHAR2)
  2  IS
  3     fid UTL_FILE.FILE_TYPE := UTL_FILE.FOPEN (loc, file, 'R');
  4     line VARCHAR2(2000);
  5  BEGIN
  6     DBMS_OUTPUT.PUT_LINE (file);
  7     LOOP
  8        UTL_FILE.GET_LINE (fid, line);
  9        DBMS_OUTPUT.PUT_LINE (line);
 10     END LOOP;
 11  EXCEPTION
 12     WHEN OTHERS THEN UTL_FILE.FCLOSE (fid);
 13  END;
 14  /


SQL>








31.33.File Read with UTL_FILE
31.33.1.Show file content
31.33.2.Get a line from a file with UTL_FILE package
31.33.3.Read file
31.33.4.Read from the CLOB in chunks of 1000 characters and write to the output file