Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Spool an output file to dynamic filename

274598Nov 4 2002
Hi.

Let say I have an Oracle Script as following:

spool c:\hms_report\HMS.xls

SELECT
field1||chr(9)||field2
from table1;

spool off
exit

Question:
Currently the output file will be HMS.xls
If I run the script thrice a day, the HMS.xls will be overwrite.
Is there any way to name the output file to be HMS+sysdate ie: If I run the script on 05-Nov-2002 09:00,
the output file name will be HMS051120020900.xls
where 05 = dd
11 = mm
2002 = yyyy
0900 = hhmi

Thanks.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 3 2002
Added on Nov 4 2002
6 comments
2,478 views