write to file plsql

Solutions on MaxInterview for write to file plsql by the best coders in the world

showing results for - "write to file plsql"
Martín
26 Oct 2019
1DECLARE
2   path_file          varchar2(100):='/path/to/directory/';
3   file_name          varchar2(100):='file_name.txt';
4   out_file           utl_file.file_type;
5BEGIN
6   out_file := utl_file.fopen(path_file,file_name,'w');
7   UTL_FILE.put_line (out_file, 'Line 1');
8   UTL_FILE.put_line (out_file, 'Line 2');
9   UTL_FILE.FCLOSE(out_file);
10EXCEPTION
11  WHEN OTHERS THEN
12    IF UTL_FILE.is_open(out_file) THEN
13      UTL_FILE.fclose(out_file);
14    END IF;
15END;