#!/bin/bash
創(chuàng)新互聯(lián)建站堅持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站設(shè)計、成都做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時代的云岡網(wǎng)站設(shè)計、移動媒體設(shè)計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
#先寫一個簡單的腳本,后續(xù)使用腳本調(diào)用存儲過程
#by:亞信-張顏
export ORACLE_HOME=/opt/oracle/app/oracle_base/product/11.2.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH
#DATE_STR保存了從數(shù)據(jù)庫中返回的三個值:1小時之前的年月,12小時前的時間串,以及當前時間串
DATE_STR=(`sqlplus -s 用戶名/密碼 < set heading off set feedback off set pagesize 0 set verify off set echo off select to_char(TRUNC(SYSDATE - 1 / 24, 'HH'), 'YYYYMM'),TO_CHAR(TRUNC(SYSDATE - 1 / 2, 'HH'), 'YYYYMMDDHH24MISS'), TO_CHAR(TRUNC(SYSDATE, 'HH'), 'YYYYMMDDHH24MISS') from dual; exit; eof`) echo "`date` 開始校驗程控退訂數(shù)據(jù)......" echo "`date` 開始提取程控功能營業(yè)送開通表退訂數(shù)據(jù)" #通過監(jiān)控營業(yè)送開通工單歷史表,查詢程控功能退訂的數(shù)據(jù),當前設(shè)定為12個小時運行1次 # for REGION_ID in {891..897} do sqlplus -s 用戶名/密碼 < set heading off set feedback off set pagesize 0 set verify off set echo off insert into zyan_jiankongchengkong select bill_id, 'MBELL', create_date, sysdate from so.i_open_provision_h_${REGION_ID}_${DATE_STR[0]} where action_id = 5 and OLD_PS_PARAM like '%MBELL=1%' and (PS_PARAM is null or PS_PARAM not like '%MBELL=1%') and create_date >= TO_DATE('${DATE_STR[1]}', 'YYYYMMDDHH24MISS') and create_date < TO_DATE('${DATE_STR[2]}', 'YYYYMMDDHH24MISS'); commit; insert into zyan_jiankongchengkong select bill_id, 'CFNRCF', create_date, sysdate from so.i_open_provision_h_${REGION_ID}_${DATE_STR[0]} where action_id = 5 and OLD_PS_PARAM like '%CFNRCF=1%' and (PS_PARAM is null or PS_PARAM not like '%CFNRCF=1%') and create_date >= TO_DATE('${DATE_STR[1]}', 'YYYYMMDDHH24MISS') and create_date < TO_DATE('${DATE_STR[2]}', 'YYYYMMDDHH24MISS'); commit; exit; eof done #校驗程控功能訂購在退訂功能時是否存在訂購關(guān)系,如果存在則表示是異常,需要進一步核查: echo "`date` 開始校驗程控退訂記錄營業(yè)側(cè)訂購關(guān)系:" for REGION_ID in {891..897} do sqlplus -s 用戶名/密碼 < set heading off set feedback off set pagesize 0 set verify off set echo off delete from zyan_jiankongchengkong a where create_date <> (select max(create_date) from zyan_jiankongchengkong b where a.bill_id = b.bill_id and a.func_name = b.func_name) and a.done_date>TO_DATE('${DATE_STR[2]}', 'YYYYMMDDHH24MISS'); commit; delete from zyan_jiankongchengkong a where not exists (select 1 from so.ins_user_${REGION_ID} b, so.ins_prod_${REGION_ID} c, so.ins_off_ins_user_${REGION_ID} f where a.bill_id = b.bill_id and c.prod_id in (121030512001, 121030512002) and b.user_id = c.user_id and c.user_id = f.user_id and c.offer_inst_id = f.offer_inst_id and b.region_id=f.region_id and f.expire_date > sysdate and c.expire_date > sysdate and c.effective_date < a.create_date and c.create_date and exists (select 1 from so. ins_user_${REGION_ID} g where a.bill_id = g.bill_id) and a.func_name = 'MBELL' and a.done_date>TO_DATE('${DATE_STR[2]}', 'YYYYMMDDHH24MISS'); commit; delete from zyan_jiankongchengkong a where not exists (select 1 from so.ins_user_${REGION_ID} b, so.ins_prod_${REGION_ID} c, so.ins_off_ins_user_${REGION_ID} f where a.bill_id = b.bill_id and c.prod_id in (121030505101) and b.user_id = c.user_id and c.user_id = f.user_id and c.offer_inst_id = f.offer_inst_id and b.region_id=f.region_id and f.expire_date > sysdate and c.expire_date > sysdate and c.effective_date < a.create_date and c.create_date and exists (select 1 from so. ins_user_${REGION_ID} g where a.bill_id = g.bill_id) and a.func_name = 'CFNRCF' and a.done_date>TO_DATE('${DATE_STR[2]}', 'YYYYMMDDHH24MISS'); commit; exit; eof done echo "`date` 本次校驗完成!" echo ""
網(wǎng)站欄目:shell腳本:數(shù)據(jù)庫業(yè)務(wù)監(jiān)控
標題鏈接:http://weahome.cn/article/pjseoi.html