# TSTdb.def: Tests Local Database Access # $Id: TSTdb.def,v 1.16 2008/02/25 17:32:56 mschenke Exp $ # ARCS: $Header: /home/cvs/repository/RDA_4/src/scripting/lib/modules/TSTdb.def,v 1.16 2008/02/25 17:32:56 mschenke Exp $ # # Change History # 20080225 MSC Change the copyright notice. =head1 NAME TSTdb - Tests Database Access =head1 DESCRIPTION =cut echo tput('bold'),'Processing local database test module ...',tput('off') =pod This test module loads the passwords encoded in the setup file. =cut echo 'Setting logins ...' # Get the current login var $log = setSqlLogin() # Define the SQL logins loop $key (grepSetting('^SQL_PASSWORD_')) {echo " Set the password for '",substr($key,13),"'" call setSqlLogin(substr($key,13),unpack('u',getSetting($key))) } loop $key (grepSetting('^SQL_PASS_\d+$')) {var ($usr,$sid) = split('\@',getSetting(replace($key,'_PASS_','_USER_')),2) call setSqlLogin($usr,unpack('u',getSetting($key)),$sid) } # Restore the current login call setSqlLogin($log) =pod It looks for F in the command path and displays the corresponding path when found. =cut echo 'Looking for sqlplus ...' macro check_sqlplus {var $cmd = getSetting('SQL_COMMAND','sqlplus') if or(isVms(),isAbsolute($cmd)) return replace(testCommand(concat($cmd,' -V')),' -V$') return findCommand($cmd) } if !check_sqlplus() {call displayText('No sqlplus',true) return } echo ' ',last =pod It looks for F in the command path and displays related information (such as path, checksum, permissions, and size). Displayed information is platform-specific. =cut echo 'Looking for oracle ...' if findCommand('oracle') {var $pgm = last if findCommand('cksum') echo ' checksum: ',command(concat('cksum ',$pgm)) else echo ' ',$pgm if isUnix() echo ' ',command(concat('ls -l ',$pgm)) } =pod It checks the settings for a database connection. C and C must be defined in the setup file. A warning is issued if C is found. =cut echo 'Checking settings ...' if getEnv('TWO_TASK') echo ' TWO_TASK=',last,' ',\ tput('reverse'),'(but will be ignored)',tput('off') var $ORACLE_HOME = getSetting('ORACLE_HOME') if !$ORACLE_HOME {call displayText('TSTdb: no ORACLE_HOME',true) return } echo ' ORACLE_HOME=',$ORACLE_HOME var $ORACLE_SID = getSetting('ORACLE_SID') if !$ORACLE_SID {call displayText('TSTdb: no ORACLE_SID',true) return } echo ' ORACLE_SID=',$ORACLE_SID =pod It executes a simple query in the database with F. =cut echo 'Testing sqlplus access to the database connection ...' if getSetting('SQL_SYSDBA') var $dba = ' AS SYSDBA' echo " using '",getSetting('SQL_LOGIN'),$dba,"'" call setSqlTrace(setTrace()) if testSql() {echo getSqlMessage() call displayText('TSTdb: connection error',true) return } echo tput('reverse'),'Successful access to the database',tput('off') =head1 COPYRIGHT NOTICE Copyright (c) 2002-2008, Oracle. All rights reserved. =head1 TRADEMARK NOTICE Oracle, JD Edwards, PeopleSoft, and Siebel are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. =cut