sql files

This commit is contained in:
dheepa
2021-07-02 08:40:37 +00:00
commit a0d3257be0
154 changed files with 49773 additions and 0 deletions

61
scripts/file_move.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/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 )
user=${credentials[user]}
password=${credentials[password]}
host=${credentials[host]}
db=${credentials[db]}
protocol=${credentials[protocol]}
server=${credentials[server]}
postgres_con="psql -A -t postgresql://$user:$password@$host/$db"
filesyspks=`$postgres_con -q -c "select file_syspk from fw_core.fw_jobctl_file_runschedule where latest_runschedule_flag='1' /*and end_status_note='TRX_completed'*/;"`
for filesyspk in ${filesyspks}
do
IFS="|" read name endstatus endnote <<<`$postgres_con -c "select file_name,end_status,end_status_note from fw_core.fw_jobctl_file_runschedule where file_syspk=$filesyspk"`
filename=$(echo $name | sed 's/[[:space:]]/\\ /g')
if [ $endstatus == "success" -a $endnote == 'TRX_completed' ]
then
echo " moving file:$filename to processed folder"
move=$(echo "mv $homeDir/files/landing/$filename $homeDir/files/processed/$filename")
eval $move
else
echo "moving file: $filename to error_file folder "
move=$(echo "mv $homeDir/files/landing/$filename $homeDir/files/error_file/$filename")
eval $move
fi
$postgres_con -q -c "update fw_core.fw_jobctl_runschedule_jobstep set end_status_note ='file_movement_completed', end_status='success',end_time = now() where job_script_type = 'shell_script' and latest_runschedule_flag='1' and job_name= 'file_cleanup'"
echo -e ' '
done
#$postgres_con -c "insert into fw_core.track_jobstep select *,'move_check' from fw_core.fw_jobctl_runschedule_jobstep;"
#$postgres_con -c "insert into fw_core.track_file select *,'move_check' from fw_core.fw_jobctl_file_runschedule;"
#$postgres_con -c "insert into fw_core.track_file_sheet select *,'move_check' from fw_core.fw_jobctl_file_sheet_runschedule;"