Spooling to a dynamic file name with SQL*Plus

From: dramos <dan.ramos_at_gartner.com>
Date: 29 Jun 2001 13:33:56 -0700
Message-ID: <641f8b7.0106291233.50a9236d_at_posting.google.com>


I am brand new to using Oracle and SQL*Plus. I have inherited some reports that are written for SQL*Plus. The output of the reports are now spooled to hardcoded file name. I need to be able to generate a file name that includes the date the report was run. I wrote the following lines of code to generate a file name and to send the report to the file.

VARIABLE TST CHAR(50)
SELECT 'CORE_TOPIC_REPORT_' || TO_CHAR(sysdate,'MM-DD-YYYY') || '.DOC'  INTO :TST FROM dual;
SPOOL TST; I have verified that the variable TST does indeed get the correct file name but the SPOOL command seems to treat TST as string rather than a variable. Am I doing something incorrectly? Any suggestions? Thanks in advance. Received on Fri Jun 29 2001 - 22:33:56 CEST

Original text of this message