if [ -z "$1" ] ; then
echo "你沒有輸入執行該shell的參數"
exit;
fi
if [ "$1" != "jf" ] && [ "$1" != "jh" ] ; then
echo "請輸入要上傳的伺服器名稱:jf 經分,jh 稽核"
exit;
fi
CUR_YEAR=`date +"%Y"`
month=$(date "+%m"|sed '/^0/ s/0//')
permonth=`expr $month - 1`
month_len=`expr length $permonth`
if [ "$month_len" = "1" ]; then
v_month=0$permonth
elif [ "$month_len" = "2" ]; then
v_month=$permonth
elif [ "$permonth" = "0" ]; then
v_month=`12`
fi
LASTMONTH=${CUR_YEAR}${v_month}
#LASTMONTH=201202
#v_month="02"
VALUE=`sqlplus -s chanxxxlzb/xxxx@chzzz<<EOF
set heading off;
set feedback off;
set pagesize 0;
set verify off;
set echo off;
select count(*) from b_INFO_CLEAR_OWE where acct_month='${LASTMONTH}';
exit;
EOF`
echo "**************************";
echo $VALUE;
echo "**************************";
begin=1;
end=1000000;
file_seq=1;
temp=`expr $VALUE \% 1000000`
echo $temp
temp1=`expr $VALUE / 1000000`
if [ $temp -gt 0 ]; then
temp1=`expr $temp1 + 1`
fi
while [ $file_seq -le $temp1 ]
do
echo "第${file_seq}檔案"
strfile_seq_1=`printf "%03d\n" $temp1`
strfile_seq_2=`printf "%03d\n" $file_seq`
strfile_seq=${strfile_seq_1}${strfile_seq_2}
echo ${strfile_seq} ${begin} ${end}
if [ "$1" = "jf" ]; then
exp_month_jf execsql exp_month_clear_owe file_seq ${strfile_seq} begin ${begin} end ${end}
elif [ "$1" = "jh" ]; then
exp_month_jh execsql exp_month_clear_owe file_seq ${strfile_seq} begin ${begin} end ${end}
fi
sleep 1
begin=`expr $begin + 1000000`
end=`expr $end + 1000000`
file_seq=`expr $file_seq + 1`
strfile_seq="";
done