中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 数据库开发 > 数据库综合
Oracle索引表的使用(Table Index)
作者:未知 时间:2005-07-27 23:38 出处:CSDN 责编:chinaitpower
              摘要:Oracle索引表的使用(Table Index)

create or replace procedure proc_XXX(
        p_iBillMonth    in  number,
        p_tab           in  number,       
        p_nStatus       out number,
        p_szErrorMsg    out varchar2
)
is
        type t_cur is ref cursor;
        v_ser           t_cur;
       v_iAccId        number(11);
       v_iSubId        number(10);
       v_strDetail     varchar2(4000);
        v_noDetail      varchar2(4000);
        v_NewDetail     varchar2(4000);           
       v_strSql        varchar2(4000); 
        v_BeginDate     varchar2(14);
        v_EndDate       varchar2(14);
        v_RowId         rowid;
        v_iLen          number(2);
        v_AccCode       varchar2(7);
        v_strFee        varchar2(9);
        v_strCount      varchar2(7);
        v_strUnit       varchar2(12);
        v_NoWnerCode    number;
        v_SumId         number;
        v_iTemp         number;
        TYPE detail_param IS RECORD
        (
          acc_code         number(7),
          fee              number(9),
          time             number(1),
          cout             number(7),
          unit             number(12)
        );
        TYPE detail_param_list IS TABLE OF detail_param INDEX BY BINARY_INTEGER;
        v_noowner_detail_param_list detail_param_list;
        v_owner_detail_param_list   detail_param_list;
begin
        v_strSql:=' select acc_id,sub_id,to_char(begin_date,''yyyymmddhh24miss''),'
             ||' to_char(end_date,''yyyymmddhh24miss''),detail_data,rowid from sum_noowner_'||p_iBillMonth
                ||' where mod(acc_id,10)='||p_tab;
        open v_ser for v_strSql;
        loop
         <<nextsub>>
         fetch v_ser into v_iAccId,v_iSubId,v_BeginDate,v_EndDate,v_noDetail,v_RowId;
         exit when v_ser%notfound;  
       
     for i in 0..length(v_noDetail)/36-1 loop
          v_noowner_detail_param_list(i+1).acc_code:=substr(v_noDetail,i*36+1,7);
            v_noowner_detail_param_list(i+1).fee:=substr(v_noDetail,i*36+8,9);
            v_noowner_detail_param_list(i+1).time:=substr(v_noDetail,i*36+17,1);
            v_noowner_detail_param_list(i+1).cout:=substr(v_noDetail,i*36+18,7); 
            v_noowner_detail_param_list(i+1).unit:=substr(v_noDetail,i*36+25,12);         
     end loop;
    
     for i in 0..length(v_strDetail)/36-1 loop
          v_owner_detail_param_list(i+1).acc_code:=substr(v_strDetail,i*36+1,7);
            v_owner_detail_param_list(i+1).fee:=substr(v_strDetail,i*36+8,9);
            v_owner_detail_param_list(i+1).time:=substr(v_strDetail,i*36+17,1);
            v_owner_detail_param_list(i+1).cout:=substr(v_strDetail,i*36+18,7); 
            v_owner_detail_param_list(i+1).unit:=substr(v_strDetail,i*36+25,12);  
     end loop;                 
          
         for i in v_owner_detail_param_list.first..v_owner_detail_param_list.last loop
               if v_owner_detail_param_list.EXISTS(i) THEN
                 if v_noowner_detail_param_list.COUNT>0 then
                  for j in v_noowner_detail_param_list.first..v_noowner_detail_param_list.last loop   
                      if v_noowner_detail_param_list.EXISTS(j) THEN
                         if v_noowner_detail_param_list(j).acc_code=v_owner_detail_param_list(i).acc_code then
                            v_owner_detail_param_list(i).fee:=
                              v_owner_detail_param_list(i).fee+v_noowner_detail_param_list(j).fee;
                            v_owner_detail_param_list(i).time:=
                              v_owner_detail_param_list(i).time+v_noowner_detail_param_list(j).time;
                            v_owner_detail_param_list(i).cout:=
                              v_owner_detail_param_list(i).cout+v_noowner_detail_param_list(j).cout;
                            v_owner_detail_param_list(i).unit:=
                              v_owner_detail_param_list(i).unit+v_noowner_detail_param_list(j).unit;                  
                            v_noowner_detail_param_list.delete(j);
                         end if;   
                      end if;
                   end loop;
                 end if;
               end if;
         end loop;
       
         if v_noowner_detail_param_list.COUNT>0 then
              for k in v_noowner_detail_param_list.first..v_noowner_detail_param_list.last loop               
                  if v_noowner_detail_param_list.EXISTS(k) THEN
                     v_owner_detail_param_list(v_owner_detail_param_list.COUNT + 1).acc_code:=
                       v_noowner_detail_param_list(k).acc_code;
                     v_owner_detail_param_list(v_owner_detail_param_list.COUNT + 1).fee:=
                       v_noowner_detail_param_list(k).fee;
                     v_owner_detail_param_list(v_owner_detail_param_list.COUNT + 1).time:=
                       v_noowner_detail_param_list(k).time;
                     v_owner_detail_param_list(v_owner_detail_param_list.COUNT + 1).cout:=
                       v_noowner_detail_param_list(k).cout;
                     v_owner_detail_param_list(v_owner_detail_param_list.COUNT + 1).unit:=
                       v_noowner_detail_param_list(k).unit;
                  end if;
              end loop;
         end if;
           
         for i in v_owner_detail_param_list.first..v_owner_detail_param_list.last loop                   
             if v_owner_detail_param_list.EXISTS(i) THEN
               v_AccCode:=v_owner_detail_param_list(i).acc_code;
            v_iLen:=length(v_AccCode);   
            while 7-v_iLen>0 loop
             v_AccCode:=' '||v_AccCode;
             v_iLen:=length(v_AccCode);
            end loop;
                      
               v_strFee:=v_owner_detail_param_list(i).fee;
            v_iLen:=length(v_strFee);   
            while 9-v_iLen>0 loop
             v_strFee:=' '||v_strFee ;
             v_iLen:=length(v_strFee);
            end loop;
   
               v_strCount:=v_owner_detail_param_list(i).cout;
            v_iLen:=length(v_strCount);
            while 7-v_iLen>0 loop 
             v_strCount:=' '||v_strCount ;
             v_iLen:=length(v_strCount);
            end loop;
                 
            v_strUnit:=v_owner_detail_param_list(i).unit;
            v_iLen:=length(v_strUnit);
            while 12-v_iLen>0 loop
             v_strUnit:=' '||v_strUnit ;
             v_iLen:=length(v_strUnit);
            end loop;                 
               v_NewDetail:=v_NewDetail||v_AccCode||v_strFee
                          ||v_owner_detail_param_list(i).time||v_strCount||v_strUnit;                 
             end if;
         end loop;   
         v_owner_detail_param_list.delete; 
        
         v_NewDetail:='';
        end loop;
        close v_ser;
 
        p_nStatus:=0;
       p_szErrorMsg:='Succeed to finish proc_no2ower.';
       return;
exception
 when others then
  p_nStatus:=-1;
    p_szErrormsg:='encounter a exception,sqlcode:'||sqlcode
                ||',sqlerrm:'||sqlerrm||'v_sql:'||v_strSql;
  return;
end proc_XXX;


关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有