Skip to Main Content

Oracle Database Discussions

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!

How to append timestamp to log file in SQL*Plus ?

james_pMay 9 2013 — edited May 10 2013
Version: 11.2.0.3
Platform : RHEL 5.8 (But I am looking for platform independant solution)


I want to append the timestamp to spooled log file name in SQL*Plus.
The spooled log filename should look like
WMS_APP_23-March-2013.log
I tried the following 3 methods found in the google. But none of them worked !


I tried this
col sysdt noprint new_value sysdt_var
SELECT TO_CHAR(SYSDATE, 'yyyymmdd_hh24miss') sysdt FROM DUAL;
spool run_filename_&sysdt_var.Log
as suggested in
http://power2build.wordpress.com/2011/03/11/sqlplus-spool-name-with-embedded-timestamp/

and this
spool filename with timestamp
col sysdt noprint new_value sysdt
SELECT TO_CHAR(SYSDATE, 'yyyymmdd_hh24miss') sysdt FROM DUAL;
spool run_filename_&sysdt..Log
as suggested in

http://powerbuildev.wordpress.com/2011/03/11/sqlplus-spool-name-with-embedded-timestamp/


and this
column tm new_value file_time noprint
select to_char(sysdate, 'YYYYMMDD') tm from dual ;
prompt &file_time
spool logfile_id&file_time..log
as suggested in
30956



None of the above worked in RHEL or MS DOS. Any workaround ?
This post has been answered by Jon Stone on May 10 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 7 2013
Added on May 9 2013
6 comments
35,342 views