Oracle 基础应用。

函数返回游标类型的方法.以下是我写的一个返回游标类型的函数,但是我返回的游标总是空的,里面是有记录的。我下在想办法解决。贴下源代码:

CREATE OR REPLACE Function MXL_QUERY_TBCHANGE_SUM  return sys_refcursor As  out_curemp sys_refcursor;

Begin

    Open out_curemp For Select t.*,t1.* ,(t.recivemoney-t1.cancelmoney) As realmoney From
          (Select cunit_id, Count(*) As recivecount , sum(a.ncharge_fee)/100 As recivemoney
              From tbcharge_fee a Where a.bsuccess=1
              Group By a.cunit_id) t,
          (Select cunit_id,Count(*) As cancelcount ,Sum(b.ncharge_fee)/100 As cancelmoney
              From tbcharge_fee b Where b.nbcancel_fee=1
              Group By b.cunit_id) t1
          Where t.cunit_id=t1.cunit_id(+); 
     Return out_curemp;
End;

 

CREATE OR REPLACE Procedure MXL_CBM_CHANGE_SUM(begindate varchar2,enddate Varchar2,userid varchar2)
As
 bdate  Date;
 edate  Date;
Begin
       bdate:=to_date(begindate,'yyyy-MM-dd');
     edate:=to_date(enddate || ' 23:59:59','yyyy-MM-dd HH24:MI:SS');
       ----插入短信营业厅代理商收费汇总表  cperiod:帐期的格式:YYYYMM
       Insert Into cbm_charge_sum(nserial, cunit_code, cuser_id, cperiod, cchannel_type, ncharge_fee_count, ncharge_fee_sum, ncancel_fee_count, ncancel_fee_sum, n_real_fee, dtsum_date, szsum_userid, cnote)
     Select seq_cbm_changesum.nextval,t.cunit_id,'tbunit',substr(to_char(to_date(begindate,'yyyy-MM-dd'),'yyyymmdd'),0,6),
     'tbunit',t.recivecount,t.recivemoney,t1.cancelcount,t1.cancelmoney,
     (t.recivemoney-t1.cancelmoney) As realmoney,Sysdate,userid,'短信营业厅代理商收费汇总' From
          (Select cunit_id, Count(*) As recivecount , sum(a.ncharge_fee)/100 As recivemoney
              From tbcharge_fee@smsdblink a Where a.bsuccess=1 And a.dtcomplete>=bdate And a.dtcomplete<=edate
              Group By a.cunit_id) t,
          (Select cunit_id,Count(*) As cancelcount ,Sum(b.ncharge_fee)/100 As cancelmoney
              From tbcharge_fee@smsdblink b Where b.nbcancel_fee=1 And b.dtcancel>=bdate And b.dtcancel<=edate
              Group By b.cunit_id) t1
          Where t.cunit_id=t1.cunit_id(+);
End;

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值