#!/bin/sh
print_error(){
now=$(date +"%Y-%m-%d %T")
echo "[$now] ERROR: $1"
}
password=""
env=$1
if [[ $env = "test" ]]; then
. test.env
elif [[ $env = "dev" ]]; then
. dev.env
else
print_error "Invalid parameter : $env"
return 1
fi
i
sqlplus $username/$password@$host:$port/$dbname <<EOF
WHENEVER SQLERROR EXIT SQL.SQLCODE
truncate table your-table;
EOF
result_code=$?
if [ $result_code -eq 1 ]; then
print_error "DB Connect Failed"
return 1
elif [ $result_code -ne 0 ]; then
print_error "SQL ERROR:$result_code"
return 1
fi
echo "[$(date +"%Y-%m-%d %T")] LOG: Success!"
#!/bin/sh
print_error(){
now=$(date +"%Y-%m-%d %T")
echo "[$now] ERROR: $1"
}
password=""
env=$1
if [[ $env = "test" ]]; then
. test.env
elif [[ $env = "dev" ]]; then
. dev.env
else
print_error "Invalid parameter : $env"
return 1
fi
if [ ! -f $filepath/$csvfilename ]
then
print_error "$csvfilename does not exist"
return 1
fi
if [ ! -f $filepath/$ctlfilename ]
then
print_error "$ctlfilename does not exist"
return 1
fi
sqlldr $username/$password@$host:$port/$dbname control=$ctlfilename log=$logfilename bad=$badfilename data=$csvfilename
if [ $? -eq 0 ]
then
echo "[$(date +"%Y-%m-%d %T")] LOG: Success!"
else
print_error "Import CSV Failed : $?"
fi