write to file plsql
DECLARE
path_file varchar2(100):='/path/to/directory/';
file_name varchar2(100):='file_name.txt';
out_file utl_file.file_type;
BEGIN
out_file := utl_file.fopen(path_file,file_name,'w');
UTL_FILE.put_line (out_file, 'Line 1');
UTL_FILE.put_line (out_file, 'Line 2');
UTL_FILE.FCLOSE(out_file);
EXCEPTION
WHEN OTHERS THEN
IF UTL_FILE.is_open(out_file) THEN
UTL_FILE.fclose(out_file);
END IF;
END;