Sunday, December 2, 2012

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 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. 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.sql


    Second file:

    SET PAGESIZE 1000 LINESIZE 200 ECHO OFF TRIMS ON FEEDBACK OFF HEA OFF
    SPOOL C:\dir_out\info.txt
    @inicial.sql;
    SPOOL OFF


    You have any idea.???

    Thanks....

    ReplyDelete
    Replies
    1. can you please rephrase your question , sorry i didn't understand you.

      Delete