Append DateTime to Spool File

From NazimWIKI
Jump to navigation Jump to search

This is how you append the date/time to an output spool file in SQL *Plus:

-- This construct is used to select a value into a user variable 
SQL> COLUMN dttm NEW_VALUE v_dttm NOPRINT;
-- Here we see the user variable data being passed in, i.e. the date and time format. 
-- Note I have not used spaces, colons etc in between my date and time strings as sometimes these can lead to SP-0332 Spooling Errors.
SQL> SELECT to_char(sysdate,'yyyymmddhh24miss') dttm from DUAL;
-- Note: the two fullstops (..) are deliberate 
SQL> spool filename_&v_dttm..log