
Installgen
Features and Benefits
Installgen
Demo Available for download...
Bookmark This Page

#! /usr/local/bin/perl
# script: c:\server_scripts\prod3_standby_startup_service.pl
# (renamed from 81_prod3_standby_startup_service_1.pl)
# Features: This perl script runs during system startup to startup the
# standby database instance in managed recovery mode.
#
# Usage: Configured as service: OracleStandbyStartupPROD3
# Copyright 2002 by .com Solutions Inc.
#
# ---------------------- Revision History ---------------
# Date By Changes
# 01-09-2002 dsimpson Initial Release
#
# This output file was created by Installgen version 1.38 on Thu Nov 14 17:16:25 2002. By .com Solutions Inc. www.dotcomsolutionsinc.net
use File::Find;
use Win32::Daemon;
my $file_to_rotate='';
my $State='';
# list of program and command line parameters to execute via operating system
my @proglist='';
my $temp_sql_filename = "temp_sql.sql";
my $tempsqlcode="";
# insure that environment variable is used by this perl script
$ENV{'ORACLE_SID'} = "PROD3";
Win32::Daemon::StartService();
while( SERVICE_STOPPED != ( $State = Win32::Daemon::State() ) )
{
if( SERVICE_START_PENDING == $State )
{
# Add initialization code here - starting standby database in
# managed recovery mode
# delay for 2 minutes to allow Windows to start up completely
sleep (120);
# start the database in managed recovery mode
my $tempsqlcode=<<"EOF";
echo on
spool c:\\server_scripts\\OracleStandbyStartupPROD3.log
host net stop OracleServicePROD3
host net start OracleServicePROD3
connect / as sysdba
-- make sure instance is down first
SHUTDOWN IMMEDIATE
STARTUP NOMOUNT pfile=c:\\v901\\database\\initprod3s.ora;
ALTER DATABASE MOUNT STANDBY DATABASE;
-- DELAY 0 for no delay
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DELAY 0 PARALLEL 8 DISCONNECT FROM SESSION;
SELECT process, status, thread#, sequence#, block#, blocks FROM v\$managed_standby;
exit;
EOF
open (FILE1,">$temp_sql_filename") || die ("Could not open output file $temp_sql_filename for writing. \n Does the full directory path exist?");
print FILE1 ($tempsqlcode);
# close the output file
close (FILE1);
@proglist = ("c:\\v901\\bin\\sqlplus.exe /nolog \@$temp_sql_filename");
system (@proglist);
Win32::Daemon::State( SERVICE_RUNNING );
}
elsif( SERVICE_PAUSE_PENDING == $State )
{
# Add pausing code here
Win32::Daemon::State( SERVICE_PAUSED );
}
elsif( SERVICE_CONTINUE_PENDING == $State )
{
# Add resuming code here
Win32::Daemon::State( SERVICE_RUNNING );
}
elsif( SERVICE_STOP_PENDING == $State )
{
# Add stopping code here
Win32::Daemon::State( SERVICE_STOPPED );
}
elsif( SERVICE_RUNNING == $State )
{
# This is the core functionality of the service
# Add code here to perform whatever work the
# service must accomplish. Avoid any code that
# blocks for long durations of time
# stop the service after the 1st iteration - it does not need to run continuously
Win32::Daemon::StopService();
}
sleep( 5 );
}
Win32::Daemon::StopService();

