<pre name="code" class="sql">export NLS_LANG="american_america.ZHS16GBK"
echo " set colsep |;
set echo off;
set feedback off;
set heading off;
set pagesize 0;
set termout off;
set trimout on;
set trimspool on;
set linesize 3000;
spool ./date.txt1;
select to_char((to_date('$1','YYYYMMDD')$2),'YYYYMMDD') from dual where rownum=1;
" | sqlplus query/query >/dev/null
if [ -f ./date.txt1 ]
then
cat ./date.txt1 | grep -v "^SQL>" | tr -d ' ' >./date.txt
rm -f ./date.txt1
else
exit
fi
date=`cat ./date.txt`
rm -f ./date.txt
echo $date
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
date=`echo $1 | tr -d '-'`
date1=`echo $2 | tr -d '-'`
date2=`echo $1`
date_end=`get_date $2 +1 | tr -d '-'`
while :
do
echo "alter table XXX add partition p$date values less than ($date2);"
date2=`get_date $date +1`
date=`echo $date2 | tr -d '-'`
if [ "$date" = "$date_end" ]
then
exit
fi
done