找到你要的答案

Q:how to Spool a file with name that contains timestamp in sql script?

Q:如何脱机文件名称包含在SQL脚本的时间戳?

I want to spool data from database into a file and I want the filename to have timestamp in it. For example if my file name is myData.csv I need to create a file like myData_08082015.csv. I am passing the timestamp as an argument. But I don't know how to concatenate this with the file name. I tried spool $HOME_DIR/myData_&1.csv but its working strangely. How to do it?

This is how I am executing it in sqlplus prompt
@$HOME_DIR/te.sql 18927346
Session altered.
Session altered.
Session altered.
Session altered.
And the file I am getting is myData;csv.lst

我想假脱机数据从数据库到一个文件的文件名,我要在它的时间戳。例如,如果我的文件名是mydata.csv我需要创建一个文件,如mydata_08082015.csv。我是通过时间戳作为参数。但我不知道如何将这个文件名。我试着home_dir美元/ mydata_阀芯&;1.csv但工作很奇怪。应该怎么做?

This is how I am executing it in sqlplus prompt
@$HOME_DIR/te.sql 18927346
Session altered.
Session altered.
Session altered.
Session altered.
And the file I am getting is myData;csv.lst

sql  oracle11g  sqlplus