/*
|| Oracle 11gR2: I/O Performance Tuning Series, Listing 5
||
|| Contains:
|| -- Batch commands and SQL statements to create beginning and ending
||    AWR snapshots at the start and end of each Benchmark Factory job run
||
|| that . . .
||
|| Author: Jim Czuprynski
||
*/

/* 
|| Listing 5.1:
|| Creating the MS-DOS batch commands scripts and SQL*Plus statements for creating a beginning
|| and an ending AWR snapshots at the start and end of each Benchmark Factory job run

*/

#####
# BeginningSnapshot.bat
#####
REM Makes a snapshot at the beginning of a TPC run
sqlplus -s sys/oracle@tpcdb as sysdba @C:\oraclient\10201\BeginningSnapshot.sql
exit

-----
-- SQL Script: BeginningSnapshot.sql
-- Purpose:    Creates an AWR snapshot at the beginning of a Benchmark Factory job
-----
DECLARE
   jobname char(20) := 'BeginningSnapshot';
BEGIN
    DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT;

EXCEPTION
    WHEN OTHERS THEN NULL;
END;
/
QUIT;

#####
# EndingSnapshot.bat
#####
REM Makes a snapshot at the end of a TPC run
sqlplus -s sys/oracle@tpcdb as sysdba @C:\oraclient\10201\EndingSnapshot.sql
exit

-----
-- SQL Script: EndingSnapshot.sql
-- Purpose:    Creates an AWR snapshot at the end of a Benchmark Factory job
-----
DECLARE
   taskname char(20) := 'EndingSnapshot';
BEGIN
    DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT;
    
EXCEPTION
    WHEN OTHERS THEN NULL;
END;
/
QUIT