CREATE OR REPLACE PROCEDURE read_demo (file_name VARCHAR2) IS
vSFile utl_file.file_type;
vNewLine VARCHAR2(200);
BEGIN
vSFile := utl_file.fopen(‘ORALOAD’, ‘test.txt’,‘r’);
IF utl_file.is_open(vSFile) THEN
LOOP
BEGIN
utl_file.get_line(vSFile, vNewLine);
IF vNewLine IS NULL THEN
EXIT;
END IF;
INSERT INTO test
(fld1, fld2)
VALUES
(vNewLine, file_name);
EXCEPTION
WHEN NO_DATA_FOUND THEN
EXIT;
END;
END LOOP;
COMMIT;
END IF;
utl_file.fclose(vSFile);
utl_file.frename(‘ORALOAD’, ‘test.txt’, ‘ORALOAD’, ‘x.txt’, TRUE);
EXCEPTION
WHEN utl_file.invalid_mode THEN
RAISE_APPLICATION_ERROR (-20051, ‘Invalid Mode Parameter’);
WHEN utl_file.invalid_path THEN
RAISE_APPLICATION_ERROR (-20052, ‘Invalid File Location’);
WHEN utl_file.invalid_filehandle THEN
RAISE_APPLICATION_ERROR (-20053, ‘Invalid Filehan