oracle如何取数,Oracle通过过程定期取数

---通讯助手扣费

execute immediate 'select count(1) from user_tables where table_name = upper(''ZJ201101300006_txzs_kf'')' into vv_datacnt;

if ( vv_datacnt >0 ) then

execute immediate 'drop table ZJ201101300006_txzs_kf purge';

end if;

execute immediate '

create table ZJ201101300006_txzs_kf

nologging as

select    /*+ parallel(a, 20) */

subno

,b_subno_trunk

,CALL_Date

,CALL_time

,case when ROLLBACK_FLAG = ''0'' then AFTER_MOB_FEE else 0-AFTER_MOB_FEE end AFTER_MOB_FEE_0

,case when ROLLBACK_FLAG = ''0'' then AFTER_TOLL_FEE else 0-AFTER_TOLL_FEE end AFTER_TOLL_FEE_0

,case when ROLLBACK_FLAG = ''0'' then AFTER_INF_FEE else 0-AFTER_INF_FEE end AFTER_INF_FEE_0,

msrn

from DGDM_DW.TB_DW_LS_CDR_sms_day a

where  b_subno_trunk = ''1065869506''

and deal_date >= to_date('''||vv_date_pre||'01'',''yyyymmdd'')    --上月1日

and deal_date

and (AFTER_MOB_FEE<>0 or AFTER_TOLL_FEE<>0 or AFTER_INF_FEE <>0)

and CALL_Date >= '''||vv_date_pre4||'01''             --上月1日

and call_date

'

;

/*

SET NEWPAGE NONE HEADING OFF SPACE 0 PAGESIZE 0 TRIMOUT ON TRIMSPOOL ON LINESIZE 2500 colsep | feedback off termout off pages 0

set colsep |

alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

set feedback on

*/

/*

spool ZJ201101300006_txzs_kf201102.txt

select SUBNO||'|'||round(sum(AFTER_MOB_FEE_0+AFTER_TOLL_FEE_0+AFTER_INF_FEE_0)/100,2)||'|' from ZJ201101300006_txzs_kf

group by subno;

spool off;

exit

*/

---天气预报月租扣费

execute immediate 'select count(1) from user_tables where table_name = upper('''||'ZJ201101300004_121_bi'||vv_date_pre||''')' into vv_datacnt;

if ( vv_datacnt >0 ) then

execute immediate 'drop table ZJ201101300004_121_bi'||vv_date_pre||' purge';

end if;

execute immediate '

create table ZJ201101300004_121_bi'||vv_date_pre||'

nologging as

select    /*+ parallel(a,16) */

a.subno,

case when ROLLBACK_FLAG  = ''0'' then AFTER_MOB_FEE else 0-AFTER_MOB_FEE end AFTER_MOB_FEE_0

,case when ROLLBACK_FLAG = ''0'' then AFTER_TOLL_FEE else 0-AFTER_TOLL_FEE end AFTER_TOLL_FEE_0

,case when ROLLBACK_FLAG = ''0'' then AFTER_INF_FEE else 0-AFTER_INF_FEE end AFTER_INF_FEE_0

,msrn,

imsi

from DGDM_DW.TB_DW_LS_CDR_sms_day a

where a.bus_type = ''52''

and a.subbus_type=''15''

and a.deal_date >= to_date('''||vv_date_pre||'01'',''yyyymmdd'')

and a.deal_date <= to_date('''||vv_date_now||'03'',''yyyymmdd'')

and a.CALL_Date >= '''||vv_date_pre4||'01''

and a.CALL_Date

'

;

---导出

/*

SET NEWPAGE NONE HEADING OFF SPACE 0 PAGESIZE 0 TRIMOUT ON TRIMSPOOL ON LINESIZE 2500 colsep | feedback off termout off pages 0

set colsep |

set feedback on

et colsep |

alter session set nls_date_format='yyyy-mm-dd';

spool ZJ201101300004_121_bi201102.txt

select subno||'|'||

round(sum(nvl(AFTER_MOB_FEE_0,0)+nvl(AFTER_TOLL_FEE_0,0)+nvl(AFTER_INF_FEE_0,0)),2)/100||'|'||

msrn||'|'

from ZJ201101300004_121_bi201102

group by subno,msrn;

spool off;

*/

---短信回执

execute immediate 'select count(1) from user_tables where table_name = upper(''ZJ201101300006_dxhz_kf'')' into vv_datacnt;

if ( vv_datacnt >0 ) then

execute immediate 'drop table ZJ201101300006_dxhz_kf purge';

end if;

execute immediate '

create table ZJ201101300006_dxhz_kf

nologging as

select    /*+ parallel(a,20)*/

subno

,b_subno_trunk

,CALL_Date

,CALL_time

,case when ROLLBACK_FLAG=''0'' then AFTER_MOB_FEE else 0-AFTER_MOB_FEE end AFTER_MOB_FEE_0

,case when ROLLBACK_FLAG=''0'' then AFTER_TOLL_FEE else 0-AFTER_TOLL_FEE end AFTER_TOLL_FEE_0

,case when ROLLBACK_FLAG=''0'' then AFTER_INF_FEE else 0-AFTER_INF_FEE end AFTER_INF_FEE_0,

msrn

from DGDM_DW.TB_DW_LS_CDR_sms_day a

where  b_subno_trunk = ''10658689''

and deal_date >= to_date('''||vv_date_pre||'01'',''yyyymmdd'')

and deal_date

and (AFTER_MOB_FEE <> 0 or AFTER_TOLL_FEE <> 0 or AFTER_INF_FEE <> 0)

and a.CALL_Date >= '''||vv_date_pre4||'01''

and a.CALL_Date

'

;

/*

SET NEWPAGE NONE HEADING OFF SPACE 0 PAGESIZE 0 TRIMOUT ON TRIMSPOOL ON LINESIZE 2500 colsep | feedback off termout off pages 0

set colsep |

set feedback on

et colsep |

alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

spool ZJ201101300006_dxhz_kf.txt

select a.subno||'|'||

a.msrn||'|'||

a.b_subno_trunk||'|'||

((a.AFTER_MOB_FEE_0+a.AFTER_TOLL_FEE_0+a.AFTER_INF_FEE_0))/100||'|'

from ZJ201101300006_dxhz_kf a

where 1=1;

spool off;

*/

--来电提醒扣费

execute immediate 'select count(1) from user_tables where table_name = upper(''ZJ201101300006_ldtx_kf'')' into vv_datacnt;

if ( vv_datacnt >0 ) then

execute immediate 'drop table ZJ201101300006_ldtx_kf purge';

end if;

execute immediate '

create table ZJ201101300006_ldtx_kf

nologging as

select    /*+ parallel(a, 20) */

a.subno

,b_subno_trunk

,CALL_Date

,CALL_time

,case when ROLLBACK_FLAG = ''0'' then AFTER_MOB_FEE else 0-AFTER_MOB_FEE end AFTER_MOB_FEE_0

,case when ROLLBACK_FLAG = ''0'' then AFTER_TOLL_FEE else 0-AFTER_TOLL_FEE end AFTER_TOLL_FEE_0

,case when ROLLBACK_FLAG = ''0'' then AFTER_INF_FEE else 0-AFTER_INF_FEE end AFTER_INF_FEE_0,

a.msrn,

a.BUS_TYPE      ,     --业务类型

a.SUBBUS_TYPE       ,--子业务类型

a.RAT_TYPE           --计费类型

from DGDM_DW.TB_DW_LS_CDR_sms_day a

where b_subno_trunk = ''1065849''

and deal_date>= to_date('''||vv_date_pre||'01'',''yyyymmdd'')

and deal_date

and (AFTER_MOB_FEE<>0 or AFTER_TOLL_FEE<>0 or AFTER_INF_FEE <>0)

and a.CALL_Date >= '''||vv_date_pre4||'01''

and a.CALL_Date

union all

select    /*+ parallel(a,20) */

a.subno

,b_subno_trunk

,CALL_Date

,CALL_time

,case when ROLLBACK_FLAG = ''0'' then AFTER_MOB_FEE else 0-AFTER_MOB_FEE end AFTER_MOB_FEE_0

,case when ROLLBACK_FLAG = ''0'' then AFTER_TOLL_FEE else 0-AFTER_TOLL_FEE end AFTER_TOLL_FEE_0

,case when ROLLBACK_FLAG = ''0'' then AFTER_INF_FEE else 0-AFTER_INF_FEE end AFTER_INF_FEE_0,

a.msrn,

a.BUS_TYPE      ,     --业务类型

a.SUBBUS_TYPE       ,--子业务类型

a.RAT_TYPE           --计费类型

from DGDM_DW.TB_DW_LS_CDR_data_day a

where b_subno_trunk = ''1065849''

and deal_date>= to_date('''||vv_date_pre||'01'',''yyyymmdd'')

and deal_date

and (AFTER_MOB_FEE<>0 or AFTER_TOLL_FEE<>0 or AFTER_INF_FEE <>0)

and a.CALL_Date >= '''||vv_date_pre4||'01''

and a.CALL_Date

union all

select    /*+ parallel(a,20) */

a.subno

,b_subno_trunk

,CALL_Date

,CALL_time

,case when ROLLBACK_FLAG = ''0'' then AFTER_MOB_FEE else 0-AFTER_MOB_FEE end AFTER_MOB_FEE_0

,case when ROLLBACK_FLAG = ''0'' then AFTER_TOLL_FEE else 0-AFTER_TOLL_FEE end AFTER_TOLL_FEE_0

,case when ROLLBACK_FLAG = ''0'' then AFTER_INF_FEE else 0-AFTER_INF_FEE end AFTER_INF_FEE_0,

a.msrn,

a.BUS_TYPE      ,     --业务类型

a.SUBBUS_TYPE       ,--子业务类型

a.RAT_TYPE           --计费类型

from DGDM_DW.TB_DW_LS_CDR_gsm_day a

where b_subno_trunk = ''1065849''

and deal_date >= to_date('''||vv_date_pre||'01'',''yyyymmdd'')

and deal_date

and (AFTER_MOB_FEE<>0 or AFTER_TOLL_FEE<>0 or AFTER_INF_FEE <>0)

and a.CALL_Date >= '''||vv_date_pre4||'01''

and a.CALL_Date

'

;

/*

SET NEWPAGE NONE HEADING OFF SPACE 0 PAGESIZE 0 TRIMOUT ON TRIMSPOOL ON LINESIZE 2500 colsep | feedback off termout off pages 0

set colsep |

set feedback on

et colsep |

alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

spool ZJ201101300006_ldtx_kf201102.txt

select a.subno||'|'||

a.msrn||'|'||

a.b_subno_trunk||'|'||

((a.AFTER_MOB_FEE_0+a.AFTER_TOLL_FEE_0+a.AFTER_INF_FEE_0))/100||'|'

from ZJ201101300006_ldtx_kf a

where 1=1;

spool off;

*/

----手机证券扣费

execute immediate 'select count(1) from user_tables where table_name = upper(''ZJ201101300006_sjzj_kf'')' into vv_datacnt;

if ( vv_datacnt >0 ) then

execute immediate 'drop table ZJ201101300006_sjzj_kf purge';

end if;

execute immediate '

create table ZJ201101300006_sjzj_kf

nologging as

select /*+ parallel(a,18) parallel(b,18)*/

distinct

a.servnumber,

a.prodid,

(case when a.brand=''BrandMzone'' then ''动感地带'' else (case when a.brand = ''BrandGotone'' then ''全球通'' else ''神州行'' end)end) brand,

b.SPBIZID

from  dgdm_ods.to_cm_subs_subscriber_a a,

dgdm_ods.to_cm_Subs_SPService_a b

where a.subsid = b.subsid

and a.active = 1

and a.DEAL_DATE=to_date(to_char(sysdate-1,''yyyymmdd''),''yyyymmdd'')

and b.SPBIZID = ''13000023''

and b.status = ''1''

and b.DEAL_DATE=to_date(to_char(sysdate-1,''yyyymmdd''),''yyyymmdd'')

'

;

----彩信折扣券

execute immediate 'select count(1) from user_tables where table_name = upper('''||'tb_lzw_cxzkq_'||vv_date_pre||''')' into vv_datacnt;

if ( vv_datacnt >0 ) then

execute immediate 'drop table tb_lzw_cxzkq_'||vv_date_pre||' purge';

end if;

---手机报扣费

execute immediate '

create table  tb_lzw_cxzkq_'||vv_date_pre||' nologging as

select    /*+ parallel(a, 20) */

a.subno

,a.b_subno_trunk

,a.CALL_Date

,a.CALL_time

,case when a.ROLLBACK_FLAG=''0'' then a.AFTER_MOB_FEE else 0-AFTER_MOB_FEE end AFTER_MOB_FEE_0

,case when a.ROLLBACK_FLAG=''0'' then a.AFTER_TOLL_FEE else 0-AFTER_TOLL_FEE end AFTER_TOLL_FEE_0

,case when a.ROLLBACK_FLAG=''0'' then a.AFTER_INF_FEE else 0-AFTER_INF_FEE end AFTER_INF_FEE_0,

a.msrn

from DGDM_DW.TB_DW_LS_CDR_data_day a

where a.b_subno_trunk=''10658880''

and a.msrn=''125843''

and deal_date>= to_date('''||vv_date_pre||'01'',''yyyymmdd'')

and deal_date

and (AFTER_MOB_FEE<>0 or AFTER_TOLL_FEE<>0 or AFTER_INF_FEE <>0)

and a.CALL_Date >= '''||vv_date_pre4||'01''

and a.CALL_Date

'

;

END SP_LZW_zj201101300004;

/0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值