Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Spool command

Status
Not open for further replies.
Apr 20, 2000
41
US
Hi, I have a SQL script that uses the SPOOL command to create a text file & write some records to it. Can I build a filename from variables that use todays date/time as part of the file name? We run oracle v7.3.4

Spool c:\schedule\mydata.dat

I'd like to have the filename as

c:\schedule\abc200202131500.dat

Can I use SPOOL "variable name" then build the filename as
file = ('abc' || to_char(sysdate,12) || '.dat')

thanks
 
i know you can input a parameter into the sql file that has a date value in it so im pretty sure you can do this.
if you try putting a parameter in the filename with a date value this would be the syntax

spool c:\schedule\abc&1.dat

by default if you dont put a file extension it will make a .lst file if you pass the parameter into the script like this

@script_name to_char(sysdate,12)

that should work but dont count on it because i use oracle 6i .
later Steve. :)
 
actually you need to have 2 dots before the file extension ie
spool c:\schedule\abc&1..dat

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top