Through the SQL plus spool function, we output the daily O & M results of the database to the log file, and sometimes it needs timed output. To avoid repeated log file names, we can
Through the SQL plus spool function, we output the daily O & M results of the database to the log file, and sometimes it needs timed output. To avoid repeated log file names, we can
Through the SQL plus spool function, we output the daily O & M results of the database to the log file, and sometimes it needs to be output regularly to avoid repeated log file names ,, the output log file name can be dynamically named. This article provides an example for your reference.
1. Generate a dynamic Log File Script
Robin @ SZDB: ~> More dynamic_logfile_name. SQL
-- + = =====================================+
-- | Filename: dynamic_logfile_name. SQL |
-- | Desc: |
-- | This is only a sapmle to generate dynamic log file name |
-- | Author: Robinson |
-- | Blog: |
-- + = =====================================+
SET TERMOUT OFF ECHO OFF VERIFY OFF
SET FEEDBACK OFF
VARIABLE dt VARCHAR2 (13 );
COL dt FORMAT a15
COL report_name FORMAT a35
BEGIN
SELECT TO_CHAR (SYSDATE, 'yyyymmd_hh24mi ') INTO: dt from dual;
END;
/
PRINT dt;
COL report_name NEW_VALUE rpt_name
SELECT 'dynamic _ logfile _ '|: dt |'. log' AS report_name from dual;
PROMPT "variable rpt_name value is & rpt_name"
SPOOL & rpt_name
Alter session set nls_date_format = 'yyyymmdd hh24: mi: ss ';
Select sysdate from dual;
Spool off;
Set termout on echo on verify on;
Set feedback on;
UNDEFINE rpt_name
EXIT;