Home > Blockchain >  UNIQUE NAMES IN ORACLE PL/SQL
UNIQUE NAMES IN ORACLE PL/SQL

Time:01-26

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?

CodePudding user response:

try this

-- not tested

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

CodePudding user response:

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;
  •  Tags:  
  • Related