A SHELL SCRIPT calling the bteqshellwrapper.ksh

#!/usr/bin/ksh -eu

. $HOME/bin/var.setup

export FROM_DT_TMP_FILE=$HOME/FROM_EXTRACT_DT.tmp
export FROM_EXTRACT_DT='2000/01/01'
loopFlag=1

while [ "${loopFlag}" -eq 1 ]
do
#empty the bteq exported file, because its append mode for bteq export

echo "" > ${FROM_DT_TMP_FILE}
#call the bteq handler for updating fdbk data
bteqshellwrapper.ksh test.sql

if [[ "$?" -ne 0 ]]; then
 echo "ERROR in calling bteq wrapper"
exit 103
else
    echo "SUCCESSFUL for ${FROM_EXTRACT_DT}"
fi

#to set/unset the loop flag
bteq <<EOI
    .logon ${TDP}/${TD_USERNAME},${TD_PASSWORD}
    .set format off
    .set titledashes off
    .set echoreq off   
    .EXPORT report FILE=${FROM_DT_TMP_FILE},open
    select
      case
        when cast('${FROM_EXTRACT_DT}' as date format 'YYYY/MM/DD') <= date '2005-12-31'
          then cast(cast('${FROM_EXTRACT_DT}' as date format 'YYYY/MM/DD') + 4 as char(10))
        else 'NULL'
      end;
    .EXPORT DATA FILE=${FROM_DT_TMP_FILE},close
    .logoff
    .exit
EOI
 
if [[ "$?" -eq 0 ]];then
  while read a
  do
   FROM_EXTRACT_DT=${a}
  done < ${FROM_DT_TMP_FILE}
  echo ${FROM_EXTRACT_DT}
  if [[ "${FROM_EXTRACT_DT}" = "NULL" ]]; then
    loopFlag=0
  fi
 
else
  echo "error execution here bteq"
  exit 102
fi
done

你可能感兴趣的:(A SHELL SCRIPT calling the bteqshellwrapper.ksh)