Thursday, September 5, 2013

APPEND THE DATE AND TIME TO A SQL*PLUS OUTPUT FILENAME


APPEND THE DATE AND TIME TO A SQL*PLUS OUTPUT FILENAME
======================================================

    If you've got an output file that you SPOOL to regularly from SQL*Plus,
but you don't want to overwrite the file, you can uniquely identify it by
appending the date and time to the filename.  Here's an example:

    column date_column new_value var1
    select to_char (sysdate, 'YYYY-MM-DD-HH24MISS') || '.txt' date_column
    from   dual
    /
    spool c:\temp\filename-&var1

        < stuff you want to spool >

    spool off