awk语言与oracle数据库交互取近半年情况

#************************************************************************************
#*****************arpu 2009
#*****************get arpu of last 6 months from database
#*****************INPUT: arpu <month> <number_file_name> example: arpu 200905 file_name
#*****************OUTPUT:result.unl as the result file
#************************************************************************************

#获取月份段200901|200812|200811|200810
export GV_DATA_DATE=$1
export TV_DATE=`sqlplus -s "user/password@zjana" <<EOF
SET NEWPAGE NONE HEADING OFF SPACE 0 PAGESIZE 0\
TRIMOUT ON TRIMSPOOL ON LINESIZE 2500 colsep | feedback off termout off pages 0
select $GV_DATA_DATE||'|'||to_char(add_months(to_date($GV_DATA_DATE,'yyyymm'),-1),'yyyymm')||'|'||\
to_char(add_months(to_date($GV_DATA_DATE,'yyyymm'),-2),'yyyymm')||'|'||\
to_char(add_months(to_date($GV_DATA_DATE,'yyyymm'),-3),'yyyymm')||'|'||\
to_char(add_months(to_date($GV_DATA_DATE,'yyyymm'),-4),'yyyymm')||'|'||\
to_char(add_months(to_date($GV_DATA_DATE,'yyyymm'),-5),'yyyymm')||'|'\
from dual;
EOF`
export GV_2=`echo $TV_DATE|awk -F"|" '{print $2}'`
export GV_3=`echo $TV_DATE|awk -F"|" '{print $3}'`
export GV_4=`echo $TV_DATE|awk -F"|" '{print $4}'`
export GV_5=`echo $TV_DATE|awk -F"|" '{print $5}'`
export GV_6=`echo $TV_DATE|awk -F"|" '{print $6}'`

##DEBUG
echo GV_DATA_DATE=$GV_DATA_DATE
echo TV_DATE=$TV_DATE
echo GV_2=$GV_2
echo GV_6=$GV_6

## LOAD NUMBER
GV_FILE=$2
cat $GV_FILE|awk '{print substr($1,1,11)}' > wl_tmp_no.unl

sqlplus -s "user/password@zjana" <<EOF
truncate table wl_tmp_no drop storage;
EOF

sqlldr user/password@zjana control=wl_tmp_no.ctl rows=10000 bindsize=8192000 readsize=8192000 log=log_wl_tmp_no.
log bad=bad_wl_tmp_no.bad direct=true

sqlplus -s "user/password@zjana" <<EOF
SET NEWPAGE NONE HEADING OFF SPACE 0 PAGESIZE 0\
TRIMOUT ON TRIMSPOOL ON LINESIZE 2500 colsep | feedback off termout off pages 0
SPOOL result.tmp
select mobile_no,nvl(t1.n_arpu,0),nvl(t2.n_arpu,0),
nvl(t3.n_arpu,0),nvl(t4.n_arpu,0),nvl(t5.n_arpu,0),nvl(t6.n_arpu,0)||'|'
from wl_tmp_no
left outer join bo_valusr_new_$GV_DATA_DATE t1 on mobile_no=t1.vc_servnumber
left outer join bo_valusr_new_$GV_2 t2 on mobile_no=t2.vc_servnumber
left outer join bo_valusr_new_$GV_3 t3 on mobile_no=t3.vc_servnumber
left outer join bo_valusr_new_$GV_4 t4 on mobile_no=t4.vc_servnumber
left outer join bo_valusr_new_$GV_5 t5 on mobile_no=t5.vc_servnumber
left outer join bo_valusr_new_$GV_6 t6 on mobile_no=t6.vc_servnumber;
EOF

## remove null line and Elapsed
cat result.tmp|awk '{if ($1 ~/^1/) {print $0}}' > result.unl$

你可能感兴趣的:(oracle,F#,mobile,vc++)