Skip to main content

Reading a file in oracle

create a directory using sqlplus

sys / as sysdba


create directory

create directory test as 'C:\test'

grant access for read and write to db

Grant read,write test to public;


copy your file emp.txt with data

DECLARE
  L_HANDLER UTL_FILE.FILE_TYPE;
L_TEST VARCHAR2(1000);

BEGIN
  L_HANDLER := UTL_FILE.FOPEN('TEST', 'EMP.txt', 'R');
 UTL_FILE.GET_LINE(L_HANDLER,L_TEXT);
DBMS_OUTPUT.PUT_LINE(L_TEXT);
END;

Comments