create_sms.sh

file_path=/billing/billing1/script/yjy/create_cdr/sms
file_name=CDR201405140006.076

cat ${file_path}/${file_name}|while read name
do
#22,2,,0,303714243611121027440000020812,01,0,,,18637150322,,18637150322,,42436,10628080,XXXX,02,02,,0,0,0,,0,0,,0371,,03714,03714,3715,,20131112,102843,20131112,103226,CDR201311130000.076.13,1,000,01,,,1,,,,
msisdn=`echo $name|awk -F ',' '{print $10}'` #通过awk截取变量$name 以,为分隔符的第10个域($10)的值,并赋值给ext 这个变量
sp_code=`echo $name|awk -F ',' '{print $14}'`
service_code=`echo $name|awk -F ',' '{print $15}'`
apply_date=`echo $name|awk -F ',' '{print $33}'`
done

echo "此条话单的基本信息如下"
echo "msisdn         : ${msisdn}"
echo "sp_code        : ${sp_code}"
echo "service_code   : ${service_code}"
echo "apply_date     : ${apply_date}"
 

${file_path}/insert_sms.sh  > /dev/null

update_cdr ()
{
if [  ! -z "$2" ]
then
sqlplus  -s  old_zz/old_zz@habildb1 <<EOF
update  yjy_create_sms set $1=$2 ;
commit;
exit
EOF
fi
}

change_cdr()
{
if [  ! -z "$1" ]
then
 echo $1
else
 echo $2
fi
}

echo "请输入需要此次修改话单内容,空代表跟原来保持一致:"
echo "msisdn"
read v_msisdn
echo "sp_code"
read v_sp_code
echo "service_code"
read v_service_code
echo "apply_date"
read v_apply_date

update_cdr  msisdn   ${v_msisdn}
update_cdr  sp_code   ${v_sp_code}
update_cdr  service_code   ${v_service_code}
update_cdr  apply_date     ${v_apply_date}

echo "修改后的话单属性如下"
echo  "msisdn"
change_cdr  ${v_msisdn}    ${msisdn}
echo  "sp_code"
change_cdr  ${v_sp_code}    ${sp_code}
echo  "service_code"
change_cdr  ${v_service_code}    ${service_code}
echo  "apply_date"
change_cdr  ${v_apply_date}    ${apply_date}

 

cd ${file_path}
rm    CDRnew.cdr
sqlplus -s old_zz/old_zz@habildb1<<EOF
spool  ${file_path}/CDRnew.cdr
set head off
set linesize 1000
SET ECHO  OFF;
SET FEEDBACK OFF;
SET HEADING OFF;
SET PAGESIZE 0;
SET VERIFY OFF;
SET ARRAYSIZE 5000;
set trimout on;
set trimspool on;
select SOURCE_TYPE||','||BIZ_TYPE||','||FID||','||RR_FLAG||','||SMS_SEQ||','||CALL_TYPE||','||USER_TYPE||','||B_USER_TYPE||','||IMSI_NUMBER||','||MSISDN||','||ORIG_TON||','||OTHER_PARTY||','||DEST_TON||','||SP_CODE||','||SERVICE_CODE||','||OPER_CODE||','||CFEE_TYPE||','||CHARGE_TYPE||','||BFEE||','||IFEE||','||MFEE||','||GFEE||','||MNS_TYPE||','||SEND_STATUS||','||PRIORITY||','||INFO_LEN||','||HOME_AREA_CODE||','||CALLED_HOME_CODE||','||ISMG_CODE||','||FORW_ISMG||','||SMSC_CODE||','||IMEI||','||APPLY_DATE||','||APPLY_TIME||','||FINISH_DATE||','||FINISH_TIME||','||FILE_NO||','||RATE_TIMES||','||ERROR_CODE||','||RESERVER1||','||RESERVER2||','||RESERVER3||','||RESERVER4||','||RESERVER5||','||RESERVER6||','||RESERVER7||','||RESERVER8
From   yjy_create_sms ;
exit;
EOF

 

你可能感兴趣的:(create)