#!/bin/bash -e HOME="/home/compegence/customer" #Directories homeDir=$HOME/MMT configDir=$homeDir/conf input_file=$configDir/etl-config.txt declare -A credentials while IFS="=" read -r key value; do credentials[$key]=$value done < <( sed -e '/^\s*$/ d' -e '/^#/ d' $input_file ) #for i in ${credentials[@]}; do echo ***$i; done user=${credentials[user]} password=${credentials[password]} host=${credentials[host]} db=${credentials[db]} protocol=${credentials[protocol]} server=${credentials[server]} postgres_con="psql -X -A -t postgresql://$user:$password@$host/$db" echo "Checking Staging 1 Status" cdate=$(date +'%Y-%m-%d') value_count=`$postgres_con -c "select count(*) from fw_core.fw_jobctl_runschedule where end_status='stg1-completed' and end_time::date = date'$cdate%';"` if [ $value_count == 0 ] then echo "Staging 1 process incomplete" exit else echo "Running FTDRY Wrapper" $postgres_con -c "select staging2.fn_FTDRY_RUN();" echo "Running FTHLG Wrapper" $postgres_con -c "select staging2.fn_FTHLG_RUN();" echo "Running FTWET Wrapper" $postgres_con -c "select staging2.fn_FTWET_RUN();" echo "Running Drawbar-DBSTD Wrapper" $postgres_con -c "select staging2.fn_DBSTD_RUN();" echo "Running Drawbar-DBOECD Wrapper" $postgres_con -c "select staging2.fn_DBOECD_RUN();" echo "Running PTO-PTOSTD Wrapper" $postgres_con -c "select staging2.fn_PTOSTD_RUN();" echo "Running PTO-PTOBEN Wrapper" $postgres_con -c "select staging2.fn_PTOBEN_RUN();" echo "Running Budni Wrapper" $postgres_con -c "select staging2.fn_BUDNI_RUN();" echo "Running IHT-IHTBT30 Wrapper" $postgres_con -c "select staging2.fn_IHTBT30_RUN();" echo "Running IHT-IHTBT50 Wrapper" $postgres_con -c "select staging2.fn_IHTBT50_RUN();" echo "Running IHT-IHTBT Wrapper" $postgres_con -c "select staging2.fn_IHTBTD_RUN();" echo "Running IHT-IHTCGM Wrapper" $postgres_con -c "select staging2.fn_IHTCGM_RUN();" echo "Running IHT-IHTEMT Wrapper" $postgres_con -c "select staging2.fn_IHTEMT_RUN();" echo "Running IHT-IHTHAM Wrapper" $postgres_con -c "select staging2.fn_IHTHAM_RUN();" echo "Running IHT-IHTHSL Wrapper" $postgres_con -c "select staging2.fn_IHTHSL_RUN();" echo "Running IHT-IHTNST Wrapper" $postgres_con -c "select staging2.fn_IHTNST_RUN();" echo "Running IHT-IHTSLL Wrapper" $postgres_con -c "select staging2.fn_IHTSLL_RUN();" echo "Running Archive wrapper" $postgres_con -c "select archive.fn_block_archive();" $postgres_con -c "select transactional.fn_info_column_dq('transactional');" $postgres_con -c "select fw_core.fn_check_model_count('$cdate%');" $postgres_con -c "select fw_core.fn_table_count ('$cdate%');" $postgres_con -c "select fw_core.fn_check_mnemonic_count('$cdate%');" echo "Finished running" echo "please Check by executing below queries:" echo " select * from fw_core.db_run_status where error_timestamp::date = date'$cdate%' " echo " select * from fw_core.fw_jobctl_file_runschedule where run_schedule_date::date = date'$cdate%' " echo " select * from fw_core.fw_jobctl_file_sheet_runschedule where run_schedule_date::date = date'$cdate%'" echo " select * from fw_core.check_model_count where create_timestamp::date = date'$cdate%';" echo " select * from fw_core.check_mnemonic_count where create_time::date =date'$cdate%';" echo " select * from fw_core.check_table_stg_trx_count where create_time::date =date'$cdate%';" fi # $postgres_con -c "select transactional_fn_computation();"