I am fairly new with .shl scripting and I have a script that I was asked to update (was written in 2002), I use a scheduling program that runs the script and passes the parameters through it. The issue is when it gets to the line echo “b_JOBS general status check complete for Bus Post Date” the script stops and shows completed. The sql that is supposed to run to update the database never runs, what would be a good way to trouble shoot this to see what is going wrong? It is to me acting like the parameter needed to run the sql is never given but dont know how to prove it.
Thank you so much for your help.
#!/usr/bin/ksh
###!/usr/bin/sh
#
#PVCS Revision @(#)PNM $Workfile: uzpbccg.shl $
# uzpbccg.shl
# Copyright Public Service Company of New Mexico 2002
#
# Process to Suspend or Resume Business post date processes
# Banner 2.2.3
#
# Called with:
# Userid
# Password
# One-up Number
# Program Name
#
##########################################################################
# D Lauer Initial revision. 08/22/2002
#
#
##########################################################################
#Command file
alias whoami='/usr/bin/whoami'
CMDFILE1="$BANNER_HOME/logs/$(whoami)_uzpbccg_data.in"
# Source function definitions for SQL support -- read/write, job control, etc
# To log SQL writes and reads to logs/{basename}_sql.out, uncomment the
# debugSQL line, or create data/{basename}_sql.dbg. {basename} is WITHOUT
# the .shl ext, i.e., logs/uzpsqlt_sql.out and data/uzpsqlt_sql.dbg.
#debugSQL=true
. uzpsqlf.shl
# GET JOB SUBMISSION PARMAETERS
if [ $# -ne 4 ]; then
echo "Wrong number of parameters."
exit 1
fi
UID=$1
PSWD=$2
ONE_UP=$3
PROG=$4
# INITIALIZE THE SQL COPROCESS FOR JOB SUBMISSION
initSQL "$UID" "$PSWD" "$ONE_UP" "$PROG" || exit 1;
# VARIABLES
DesiredState=""
JobsRunning=""
JobBroken=""
StatusErr="0"
dbacc=${ORACLE_HOME}/bin/sqlplus
optn="-s"
dbid=$1
dbps=$2
ntry="${dbacc} ${optn}
${dbid}/${dbps}";export ntry
TestStr="ABCD"
AccStat=""
ScrStat=""
TStat=""
writeSQL "select b_number, b_value from b
where b_job = upper('$PROG') and b_one_up_no = $ONE_UP;"
Response=$(readSQL)
if [ -z "$Response" ]; then
errSQL "Job and One Up Number not found in database."
exit 1
elif echo "$Response" | grep -q -E "^ERROR|ORA-"; then
echo "$Response"
errSQL "Error returned from database."
exit 1
fi
echo "$Response" |
while read ParmNum ParmValue; do
if [ "$ParmNum" = "01" ]; then
DesiredState=`echo ${ParmValue} | tr [:lower:] [:upper:]`
fi
done
# Tell Banner that we are starting this job
jobStartSQL
# Set up temp files
FTPErr=$TEMP.err
# Start time
echo START `date`
# Main
# Check DB ID and password
AccStat=`echo "${TestStr}" | ${ntry} | grep -q "ERROR"; echo $?`
if [ "${AccStat}" = "0" ]
then
errSQL "Unable to log into database."
exit 1
fi
# Check if ONE db_determine_business_day_np is up
integer JobsRunning=`echo "SET HEA OFF
SELECT COUNT(what) FROM a_jobs WHERE what LIKE 'processB;';" | ${ntry}`
if [ ${JobsRunning} -ne 1 ]
then
errSQL "${JobsRunning} number of Bus post running."
exit 1
fi
# Check to see if db_determine_business_day_np is broken
JobBroken=`echo "SET HEA OFF
SELECT broken FROM a_jobs WHERE what LIKE 'processA;';" | ${ntry}`
if [ ${JobBroken} != "N" ]
then
errSQL "Business Post Date job broken.See b_JOBS"
exit 1
fi
echo "b_JOBS general status check complete for Bus Post Date"
#Suspend or Resume
if [ "${DesiredState}" = "R" ]
then
echo "Resume Requested"
echo "WHENEVER SQLERROR EXIT 9813
SET HEA OFF13
SELECT * FROM a;
UPDATE a
SET a_suspend_flag = 'N';13
COMMIT;13
SELECT * FROM a;
exit;" | ${ntry}
StatusErr=$?
fi
if [ "${DesiredState}" = "S" ]
then
echo "Suspend Requested"
echo "WHENEVER SQLERROR EXIT 9913
SET HEA OFF13
SELECT * FROM a;
UPDATE a
SET a_suspend_flag = 'Y';13
COMMIT;13
SELECT * FROM a;
exit;" | ${ntry}
StatusErr=$?
fi
#Check for a flag chg errors
if [ ${StatusErr} = "98" ]
then
errSQL "Unable Resume Error ${StatusErr}"
exit 1
elif [ ${StatusErr} = "99" ]
then
errSQL "Unable to Suspend Error ${StatusErr} "
exit 1
elif [ ${StatusErr} != "0" ]
then
errSQL "Unkown Error.Contact CSIT. Error ${StatusErr} "
exit 1
fi
# End Time
echo ENDED `date`
#REMOVE CMDFILE1
if [ -f $CMDFILE1 ]; then
rm -f $CMDFILE1
fi
# EOJ
jobEndSQL
I tried adding echo after each line to see with no results.