Anda di halaman 1dari 2

more cycle_Date_dim_recon_update.

sh
#!/bin/sh
#
# call_plan_renewal_revenue.sh
#
# Patni Data Warehouse Team
# 09-OCT-2012
#
# Usage:
#
call_plan_renewal_revenue.sh
#
The Parameter file contains details about the psql script that needs to
#
executed.
#
# ==============================================================================
#
Modifications
# Date
Inits Changes
# ----------------------------------------------------------------------------# 09-OCT-2012 MP
Initial creation
# ==============================================================================
# Program Infomation
VERDATE="Version 1.1 - 30-MAR-11 "
PROGNAME=`basename $0`
# Enable for TESTING ONLY
#set -n # Uncomment to check the script syntax without any execution
set -x # Uncomment to debug this shell script
#-------------------------------------------------------------------------------------#
# Validate if a valid envfile parameter was specified.
#-------------------------------------------------------------------------------------#
ENV_FILE=/dswork/prod_HCPT_DWH_R1_DCA/scripts/etc/param_global.config
if [ -n "${ENV_FILE}" ] #-&& -e "${ENV_FILE}"
then
source ${ENV_FILE}
else
echo "environment file is not specifiled"
exit 1
fi
#-------------------------------------------------------------------------------------#
# Setup Log file
#-------------------------------------------------------------------------------------#
DASHES="-------------------------------------------------------------------------------------"
EQUALS="====================================================================="
TSTMP=`date +%Y%m%d_%H%M`
LOG_FILE_BASE=`basename $0 | cut --delimiter=. --fields=1`
LOG_FILE=$LOG_DIR/${LOG_FILE_BASE}_${TSTMP}.log
DT_SK_ID=$1
cat /dev/null > $LOG_FILE
echo $DASHES >> $LOG_FILE
echo >> $LOG_FILE
echo "PROCESS NAME: $PROCESS_NAME" >> $LOG_FILE

echo
echo
echo
echo
echo
echo

"DB HOST: $HOST_IP" >> $LOG_FILE


"DB NAME: $DB_NAME" >> $LOG_FILE
"DB USER: $DB_USER" >> $LOG_FILE
"PROCESS LOG FILE: $LOG_FILE" >> $LOG_FILE
>> $LOG_FILE
$EQUALS >> $LOG_FILE

DTIME=`date "+%d-%m-%y %H:%M:%S"`


export PGPASSWORD=gpetl1#000
# STEP 1---> insert base table's latest set records which are not present in int
table into temp_2
echo $DASHES >> $LOG_FILE
DTIME=`date "+%d-%m-%y %H:%M:%S"`
echo "$DTIME: Starting STEP 1--->insert into temp_2" >> $LOG_FILE
echo $DASHES >> $LOG_FILE
psql -1 -h $HOST_IP -p $PORT_NUM -d $DB_NAME -U $DB_USER -v ON_ERROR_STOP=1 -a
c "update dwh.cycle_date_dim cdd
set
cycle_date_sk_id=dd.date_sk_id,
cycle_dt= dd.full_dt
from dwh.date_dim dd
where dd.date_sk_id=${DT_SK_ID}
and cdd.process_nm='RECON';"
SQL_STATUS=$?
# Check status of the sql execution
if [ "$SQL_STATUS" -eq 0 ]
then
echo >> $LOG_FILE
DTIME=`date "+%d-%m-%y %H:%M:%S"`
echo "$DTIME: STEP 1---> updated successfully" >> $LOG_F
ILE
echo >> $LOG_FILE
echo $EQUALS >> $LOG_FILE 2>&1
else
DTIME=`date "+%d-%m-%y %H:%M:%S"`
echo "$DTIME: STEP 1---> update encountered ERRORS" >> $
LOG_FILE
echo
echo
echo
exit
fi

"$DTIME: SQL STATUS=$SQL_STATUS" >> $LOG_FILE


>> $LOG_FILE
$EQUALS >> $LOG_FILE
1

Anda mungkin juga menyukai