PL-SQL code to read a file

PL-SQL code to read a file
Oracle apps ebs plsql to read a file
how to read a file using plsql

DECLARE
   fHandler   UTL_FILE.FILE_TYPE;

   buf        VARCHAR2 (4000);
BEGIN
   fHandler := UTL_FILE.FOPEN ('STUDENT_DIR', 'Details.txt', 'r');

   UTL_FILE.GET_LINE (fHandler, buf);

   DBMS_OUTPUT.put_line ('DATA FROM FILE: ' || buf);

   UTL_FILE.FCLOSE (fHandler);
EXCEPTION
   WHEN UTL_FILE.invalid_path
   THEN
      raise_application_error (
         -20000,
         'Invalid path. Create directory or set UTL_FILE_DIR.');
END;
/

Related posts: Upload your own post and refer it anywhere anytime:

Leave a Reply