I have created a directory and created an anonymous block to create a file in it. Every time if I execute the block the file is overwritten. I need it to be created as a new file. What should I do to attain this.
DECLARE
v_name utl_file.file_type;
v_count NUMBER := 0;
BEGIN
v_name := utl_file.fopen('PLSQL_DIR', 'Task1.txt', 'W');
utl_file.put_line(
v_name,
TO_CHAR(SYSDATE, 'DD/MM/YY/HH/MI')||' Data Migration Starts'
);
FOR i IN (SELECT * FROM sue_par_det_tb) LOOP
utl_file.put_line(
v_name,
i.patient_name||', '|| i.ord_date||', '|| i.mobile_number||', '|| i.refered_by
);
v_count := v_count + 1;
END LOOP;
utl_file.put_line(
v_name,
v_count||' Rows generated at '||TO_CHAR(SYSDATE, 'DD/MM/YY/HH24/MI')
);
utl_file.fclose(v_name);
END;
/