*******************************************************************************
Rem This procedure creates a command file in C:\SCRIPTS called
Rem 'arch_del.cmd' which can be scheduled to execute by using the
Rem AT command in Windows NT. This procedure is submitted as
Rem a batch job which is scheduled once a week and deletes old
Rem archives.
Rem This procedure is designed for Oracle version 7.x. For Oracle8,
Rem check trunc(time) < trunc(sysdate)-10, where time is in the DATE
Rem field and the table name is V$ARCHIVED_LOG. In version 7.x,
Rem time is VARCHAR2. The procedure uses a pre-defined package
Rem called UTL_FILE. The init.ora should be modified to include
Rem a parameter called UTL_FILE_DIR=C:\SCRIPTS so that it can
Rem write in that destination directory.
*******************************************************************************
CREATE OR REPLACE PROCEDURE sp_arch_delete AS
arch_name UTL_FILE.FILE_TYPE;
arch_file varchar2(100);
BEGIN
DECLARE CURSOR c1 IS SELECT 'del '||name name
FROM V$ARCHIVED_LOG
WHERE trunc(completion_time) < TRUNC(sysdate)-10;
*********************************************************************************************
Rem The following DBMS package procedure submits the batch job to execute
Rem the above procedure once every week. The job is submitted by connecting
Rem as internal through the Server Manager. The job executes the procedure
Rem at 7:00 p.m. on the day you submit the job and 7:00 p.m. at the interval of
Rem seven days.
********************************************************************************************
SVRMGR> VARIABLE jobno number;
5> /
*********************************************************************************************
Rem The following AT command executes F:\SCRIPTS\arch_del.cmd every
Rem Monday night at 8.00 p.m and creates a log file at F:\SCRIPTS\arch_del.log.
*********************************************************************************************
F:> at 20:00 /every:M "C:\SCRIPTS\arch_del.cmd 1>C:\SCRIPTS\arch_del.log 2>&1"
Bookmarks