Spool File With Date/Time Name

Amazing way to spool  automatically :

SET TERMOUT OFF
COLUMN today_ddmmyyyy_col NEW_VALUE today_ddmmyyyy
SELECT TO_CHAR ( SYSDATE, 'DDMMYYYY') AS today_ddmmyyyy_col
FROM dual;
SET TERMOUT ON
SPOOL log_&today_ddmmyyyy..log

Thank you
Osama Mustafa

3 thoughts on “Spool File With Date/Time Name

  1. Hello.Thanks for read this comment.I have a question.I do not fix a problem about Spool in Oracle DB.I have to out a report with extension txt with dates about a simple select (select * from emp).I apply SET commands but I do not achieve that the file output delete a line on top the file.Example:—– this appear blank line in the TXT file —–“TEXTO1″;”TEXTO2″. . . .. ….”TEXTON”;”TEXTOM”My code:First file: @salida.sqlSecond file:SET PAGESIZE 1000 LINESIZE 200 ECHO OFF TRIMS ON FEEDBACK OFF HEA OFFSPOOL C:\dir_out\info.txt@inicial.sql;SPOOL OFFYou have any idea.???Thanks….

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.