Shell脚本

文件以sh结尾命名:

CIMDB_NAME=$CIMDB_NAME
CIMDB_USERNAME=$CIMDB_USERNAME
CIMDB_PASSWD=$CIMDB_PASSWD
LOGPATH=$CIMHOME/log
Date=`date +"%Y%m%d" `

#SCRIPT_PATH="/cim/datafile/incoming/load"
SCRIPT_NAME="LOAD_CIM_ASK_FOR_LOAD_BOOK"
SCRIPT_DESC="好享贷策略名单文件"
############################################################程序开始
echo "${SCRIPT_NAME}.sh======${SCRIPT_DESC}======程序开始时间======`date +"%Y%m%d=%T"`" 
find $CIMHOME/datafile/incoming/load -name "GOODLOANBOOK*" -exec perl   -p -i -e 's/^M//g' {} \;
#1)判断数据文件是否存在
if [ -f $CIMHOME/datafile/incoming/load/GOODLOANBOOK*.txt ]
db2 -x connect to $CIMDB_NAME user $CIMDB_USERNAME using $CIMDB_PASSWD
then
    #2)加载文件
    for file in `ls $CIMHOME/datafile/incoming/load/GOODLOANBOOK*.txt`
  do
    db2 "load client from '$file' of del modified by codepage=1386 coldel, DELPRIORITYCHAR   messages '$CIMHOME/log/load/CIM_ASK_FOR_LOAD_BOOK.msglog'  replace into TMP.TMP_CIM_ASK_FOR_LOAD_BOOK nonrecoverable"
    if [ $? -ne 0 ]
    then
        echo "======load数据文件===失败======"
        exit -1
    fi
    db2 "DECLARE CUR CURSOR FOR SELECT
     ACT_RFE_NBR_TXT ,
     CSR_NME ,
     MCC_CSS ,
     RMB_CDT_LMT_AMT ,
     USD_CDT_LMT_AMT ,
     CDT_EXP_DTE ,
     RMB_CSH_CDT_LMT_AMT ,
     DFD_OTI_IND ,
     MAX_DFD_OTI_NUM ,
     MAX_IST_NUM ,
     RISK_EXPOSE_LMT
     FROM
     TMP.TMP_CIM_ASK_FOR_LOAD_BOOK
     WHERE RMB_CDT_LMT_AMT <= 50000000
     AND RMB_CSH_CDT_LMT_AMT <= 50000000
     WITH UR"
   db2 "LOAD FROM CUR OF CURSOR REPLACE INTO APP.CIM_ASK_FOR_LOAD_BOOK NONRECOVERABLE "
          if [ $? -eq 0 ]
          then
              echo "LOAD succee!"   
        mv $file  /cim/datafile/bak 
          else
              echo "======导入数据===失败======"
              exit -1
          fi 
    echo "对====== 表进行 RUNSTATS操作======`date +"%Y%m%d=%T"`"
       db2 "RUNSTATS ON TABLE  APP.CIM_ASK_FOR_LOAD_BOOK  WITH DISTRIBUTION AND INDEXES ALL"
       echo "对====== 表进行 RUNSTATS操作结束======`date +"%Y%m%d=%T"`" 
  done
else               
 echo  "======`date +"%Y%m%d"`======无数据文件===正常退出======"                                       
 echo "${SCRIPT_NAME}.sh======${SCRIPT_DESC}======无数据文件======`date +"%Y%m%d=%T"`"  
fi
db2 "DELETE FROM
      ( SELECT
                ACT_RFE_NBR_TXT ,
    CSR_NME ,
    MCC_CSS ,
    RMB_CDT_LMT_AMT ,
    USD_CDT_LMT_AMT ,
    CDT_EXP_DTE ,
    RMB_CSH_CDT_LMT_AMT ,
    DFD_OTI_IND ,
    MAX_DFD_OTI_NUM ,
    MAX_IST_NUM ,
    RISK_EXPOSE_LMT
                FROM APP.CIM_ASK_FOR_LOAD_BOOK
                WHERE  ACT_RFE_NBR_TXT IN
    (SELECT TAT.HCY_ACT_RFE_NUM
    FROM CDI.CIM_TOP_ACCT_INFO TAT
                INNER JOIN CDI.CIM_FULL_FLAG_CUST FC
                ON TAT.CUST_UNION_ID = FC.CUST_UNION_ID
                WHERE  FC.CASH_OUT_IND = '2'
                )
    WITH UR)"
if [ $? -eq 0 ]
then
 echo "delete succee!"
else
 echo "======剔除中套标识===失败======"
 exit -1
fi          
db2 "export to /cim/datafile/inner/m2r/fulldata/tmp/GOODLOANBOOK.txt of del modified by nochardel select ACT_RFE_NBR_TXT ,CSR_NME ,MCC_CSS ,RMB_CDT_LMT_AMT ,USD_CDT_LMT_AMT ,CDT_EXP_DTE ,RMB_CSH_CDT_LMT_AMT ,DFD_OTI_IND ,MAX_DFD_OTI_NUM ,MAX_IST_NUM ,RISK_EXPOSE_LMT from APP.CIM_ASK_FOR_LOAD_BOOK with ur"
if [ $? -eq 0 ]
then
 echo "export file succee!"
else
 echo "======导出数据文件===失败======"
 exit -1
fi       
db2 terminate
echo "${SCRIPT_NAME}.sh======${SCRIPT_DESC}======程序结束时间======`date +"%Y%m%d=%T"`"
############################################################程序结束

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值