Led
Led

Reputation: 1

UNIQUE NAMES IN ORACLE PL/SQL

I have a procedure that converts the result of a specific query in a CSV File which is saved in a directory in the server. My question is that is there any way that i can generate unique names for the file every time i save it?

Upvotes: 0

Views: 174

Answers (2)

EJ Egyed
EJ Egyed

Reputation: 6094

If you create a SEQUENCE, you can increment the sequence each time you go to write your file.

DECLARE
    l_filename   VARCHAR2 (200);
BEGIN
    SELECT 'somename_' || seq_name.NEXTVAL INTO l_filename FROM DUAL;
END;

Upvotes: 1

Himanshu Kandpal
Himanshu Kandpal

Reputation: 1606

try this

-- not tested

select to_char( sysdate,'yyyymmddhh24miss' ) || '.txt' File_nm from dual;
spool &File_nm ;
-- run query
spool off;

Upvotes: 2

Related Questions