create or replace procedure criaarquivo (
path in varchar2,
filename in varchar2
)
is
output_file utl_file.file_type;
begin
output_file := utl_file.fopen (path,filename, ‘W’);

for cur_rec in (select linhas from TTCPJ order by codigo) loop
utl_file.put_line (output_file, cur_rec.linhas);
end loop;

utl_file.fclose(output_file);

–exception
— when others then null;
end;
/