#!/bin/bash
#
#########################################################################################
#
# Script: BI schedule script
# Description: Script to load BI data from production
# Author: J.Minnaar / ABS Laundry Business Solutions
#
#### Changelog ##########################################################################
# 1.0, 20110406 - initial version
#########################################################################################

# script root location
export ABS_ROOTDIR=/abs/software/oracle/BI/DataLoading

# export the oracle home of the client what will be used to run the export from
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_2
export PATH=$ORACLE_HOME/bin:$PATH

#### Check Oracle home #########################################
if [ ! -d "$ORACLE_HOME" ]
then
    echo "The ORACLE_HOME setting ($ORACLE_HOME) points to a non-existing"
    echo "directory. Please check the configuration script."
    exit 1
fi

export LOGFILENAME=$ABS_ROOTDIR/BI_LOAD.LOG

touch $LOGFILENAME
echo 'start task' >> $LOGFILENAME
echo `date +%Y%b%d_%H%M%S` >> $LOGFILENAME

# sqlplus -s ABSSOLUTE/ABSSOLUTE@ABS_PROD @$ABS_ROOTDIR/execute_generatestdhistory.sql >> $LOGFILENAME
# sqlplus -s ABSSOLUTE/ABSSOLUTE@ABS_PROD @$ABS_ROOTDIR/execute_generatedptcosts.sql >> $LOGFILENAME 
sqlplus -s ABSDWHSTAGING/ABSDWHSTAGING@ABSBI @$ABS_ROOTDIR/execute_BI_staging_load.sql >> $LOGFILENAME 
sqlplus -s ABSDATAWAREHOUSE/ABSDATAWAREHOUSE@ABSBI @$ABS_ROOTDIR/execute_BI_warehouse_load.sql >> $LOGFILENAME
sqlplus -s ABSDWHSTAGING/ABSDWHSTAGING@ABSBI @$ABS_ROOTDIR/execute_BI_finalize_load.sql >> $LOGFILENAME
echo 'end task' >> $LOGFILENAME
echo `date +%Y%b%d_%H%M%S` >> $LOGFILENAME

echo . >> $LOGFILENAME