#!/usr/bin/ksh
cd ${HOME}/smp_run/smpser/bin/
if [ $# = 0 ]; then
rptday=`date '+%Y%m%d'`
else
rptday=$1
fi
rptfilename=$HOME/smp_run/smpser/temp/ocs_productcum${rptday}.rpt
if [ -f ${rptfilename}.Z ]; then
echo `date '+%m-%d-%Y'` "The table ocs_rptproduct_sum had unload Finish"
exit 1
fi
if [ "-$DBSERVERTYPE" = "-INFORMIX" ]; then
echo "The DBSERVERTYPE is Informix"
echo "unload to ${rptfilename} select * from ocs_rptproduct_sum where to_char((to_date(Countdate,'%Y%m%d') + 1 units DAY) , '%Y%m%d') = '${rptday}'"|dbaccess $SMPDBNAME
fi
if [ ! -s ${rptfilename} ]; then
echo "The table ocs_rptproduct_sum is null ${rptday}"
rm $rptfilename
exit 1
fi
if [ -f $rptfilename ]; then
cat $rptfilename |awk -F'|' '{printf("%s|%s|%s|%s|%s|%s|%s\n",$2,$3,$4,$5,$6,$7,$8)}' > tempfile
mv tempfile ${rptfilename}
compress -f ${rptfilename}
echo `date '+%m-%d-%Y'` "Process table ocs_rptproduct_sum Finish"
exit 0
fi