沉睡森林@漂在北京

          本處文章除注明“轉(zhuǎn)載”外均為原創(chuàng),轉(zhuǎn)載請(qǐng)注明出處。

            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            152 隨筆 :: 4 文章 :: 114 評(píng)論 :: 0 Trackbacks
          drop package COMMON_FUNCTION
          /

          /*==============================================================*/
          /* Database package: COMMON_FUNCTION                            */
          /*==============================================================*/
          create or replace package COMMON_FUNCTION as
             
          function GETORIGINCODEBYID (ORIGINID In Numberreturn number;
             
          function GETCOUNTYDEGREE (COUNTYID in Numberreturn Number;
             
          function GETVILLAGENAMEBYID (VILLAGEID In Numberreturn Varchar2;
             
          function GETTOWNNAMEBYID (TOWNID In Numberreturn Varchar2;
             
          function GETCOUNTYNAMEBYID (COUNTYID In Numberreturn Varchar2;
             
          function GETCOUNTYIDBYUSERID (USERID In Numberreturn NUMBER;
             
          function GETWORKSTATIONIDBYUSERID (USERID In Numberreturn NUMBER;
             
          function GETVILLAGECODEBYID (VILLAGEID In Numberreturn Varchar2;
             
          function GETTOWNCODEBYID (TOWNID In Numberreturn Varchar2;
             
          function GETCOUNTYCODEBYID (COUNTYID In Numberreturn Varchar2;
             
          function GETWORKSTATIONNAMEBYID (WORKSTATIONID In Numberreturn Varchar2;
             
          function GETCITYIDBYCOUNTYID (COUNTYID In Numberreturn Number;
             
          function GETCOUNTYIDBYTOWNID (TOWNID In Numberreturn Number;
             
          function GETHUBEIID return number;
             
          function GETCUTTYPECODEBYID (CUTTYPEID In Numberreturn number;
             
          function GETTREECODEBYID (TREEID In Numberreturn Varchar2;
             
          function GETFORESTCODEBYID (FID In Numberreturn number;
          end COMMON_FUNCTION;
          /

          create or replace package body COMMON_FUNCTION as
             
          function GETORIGINCODEBYID (ORIGINID In Numberreturn number as
             lastNum 
          number;
               
          begin
                      
          select origin.ORIG_QYDM into lastNum from GG_ORIGIN origin where origin.ORIG_ID = originId;
                    
          return lastNum;
               
          end;
             
          function GETCOUNTYDEGREE (COUNTYID in Numberreturn Number as
             DegreeNum 
          number;
               CountyCode 
          varchar(50);
               
          Begin
                      
                      
          select ct.COUN_DM
                    
          into CountyCode 
                    
          from GG_County ct 
                    
          where ct.coun_id = CountyId;
                    
                    
          --province  county
                    if trim( Substr(trim(CountyCode),3) ) = '0000' then
                          
          --degreeNum := 0;
                       return 0;
                    
          end if;
                    
                    
          --city county
                    if trim( Substr(trim(CountyCode),3) ) != '0000' and trim(Substr(trim(CountyCode),5)) = '00' then
                          
          --degreeNum := 1;
                       return 1;
                    
          end if;
                    
                    
          --county county
                    if trim( Substr(trim(CountyCode),3) ) != '0000' and trim(Substr(trim(CountyCode),5)) != '00'then
                          
          --degreeNum := 2;
                       return 2;
                    
          end if;
                    
                      
          --return DegreeNum;
               ENd;
             
          function GETVILLAGENAMEBYID (VILLAGEID In Numberreturn Varchar2 as
             villageName 
          varchar2(50);
               
          Begin
                      
          Select VILL_CM  
                    
          Into VillageName 
                    
          from GG_VILLAGE 
                    
          where VILL_ID = VillageId;
                    
                    
          return VillageName;
               
          End;
             
          function GETTOWNNAMEBYID (TOWNID In Numberreturn Varchar2 as
             villageName 
          varchar2(50);
               
          Begin
                      
          Select TOWN_XZM  
                    
          Into VillageName 
                    
          from GG_Town 
                    
          where TOWN_ID = TownId;
                    
                    
          return VillageName;
               
          End;
             
          function GETCOUNTYNAMEBYID (COUNTYID In Numberreturn Varchar2 as
             villageName 
          varchar2(50);
               
          Begin
                      
          Select COUN_MC  
                    
          Into VillageName 
                    
          from GG_County 
                    
          where COUN_ID = CountyId;
                    
                    
          return VillageName;
               
          End;
             
          function GETCOUNTYIDBYUSERID (USERID In Numberreturn NUMBER as
             countyId 
          NUMBER;
             
              
          BEGIN
                
          select  workstation.WORK_ID 
                
          into countyId 
                
          from  GG_COUNTY county,GG_USER u,GG_PERSON person,GG_WORKSTATION workstation
                
          where u.USER_ID = userId
                
          And  u.USER_RYID = person.PERS_ID
                
          And  person.PERS_WORKID = workstation.WORK_ID
                
          And workstation.WORK_XDMID = county.COUN_ID    ;
             
                     
                
          return countyId;
                
               
          END;
             
          function GETWORKSTATIONIDBYUSERID (USERID In Numberreturn NUMBER as
             workstationId 
          NUMBER;
             
               
          BEGIN
                
          select  workstation.WORK_ID 
                
          into workstationId 
                
          from  GG_USER u,GG_PERSON person,GG_WORKSTATION workstation
                
          where u.USER_ID = userId
                
          And  u.USER_RYID = person.PERS_ID
                
          And   person.PERS_WORKID = workstation.WORK_ID;
                     
                
          return workstationId;
                
                
          END;
             
          function GETVILLAGECODEBYID (VILLAGEID In Numberreturn Varchar2 as
             VillageCode 
          varchar2(50);
               TownCode 
          varchar2(50);
               CountyCode 
          varchar2(50);
               
          Begin 
                       
          select VILL_CDM Into VillageCode 
                     
          From  GG_VILLAGE 
                     
          where VILL_ID = VillageId;
                            
                     
          select town.TOWN_XZDM 
                     
          Into TownCode 
                     
          From  GG_Town town,GG_Village village  
                     
          Where   town.TOWN_ID = village.VILL_XZDMID 
                     
          And   village.VILL_ID = VillageId;
                                  
                                  
                     
          select county.COUN_DM 
                     
          Into CountyCode 
                     
          From   GG_County county,GG_town town,GG_village village 
                     
          Where village.VILL_ID = VillageId
                     
          And  town.TOWN_XDMID = county.COUN_ID
                     
          And   village.VILL_XZDMID = town.TOWN_ID;        
                     
                     
          return CountyCode || TownCode || VillageCode;
                     
               
          End;
             
          function GETTOWNCODEBYID (TOWNID In Numberreturn Varchar2 as
             TownCode 
          varchar2(50);
               CountyCode 
          varchar2(50);
               
          Begin        
                     
          select town.TOWN_XZDM Into TownCode 
                     
          From  GG_Town town   
                     
          Where   town.TOWN_ID = TownId; 
                           
                     
          select county.COUN_DM Into CountyCode 
                     
          From  GG_County county,GG_town town  
                     
          Where   town.TOWN_ID = TownId
                     
          And  town.TOWN_XDMID = county.COUN_ID;        
                      
                     
          return CountyCode  || TownCode || '000';
               
          End;
             
          function GETCOUNTYCODEBYID (COUNTYID In Numberreturn Varchar2 as
             CountyCode 
          varchar2(50);
               
          Begin 
                       
          --return 'hello';
                     select county.COUN_DM Into CountyCode 
                     
          From  GG_County county
                     
          Where   county.COUN_ID = CountyId;
                     
                     
          return CountyCode || '000'  || '000';
               
          End;
             
          function GETWORKSTATIONNAMEBYID (WORKSTATIONID In Numberreturn Varchar2 as
             workName 
          varchar(80);
               
          Begin
                      
          select workstation.WORK_DWM 
                    
          into workname 
                    
          from gg_workstation workstation 
                    
          where workstation.WORK_ID = WorkstationId;
                    
                      
          return workName;
               
          End;
             
          function GETCITYIDBYCOUNTYID (COUNTYID In Numberreturn Number as
             CityId  
          Number;
               
          Begin
                   
          select   county.COUN_SJID  Into CityId 
                 
          From  GG_County county
                 
          Where  county.COUN_ID = CountyId; 
                 
          return cityId; 
               
          End;
             
          function GETCOUNTYIDBYTOWNID (TOWNID In Numberreturn Number as
             countyId 
          Number;
               
          Begin
                      
          select   town.TOWN_XDMID  Into  countyId 
                    
          From  GG_town town
                    
          where town.TOWN_ID = TownId;
                    
                    
          return countyId;
               
          End;
             
          function GETHUBEIID return number as
             countyId 
          number;
               
          Begin
                      
          select   county.COUN_ID into countyId
                    
          from  gg_county county
                    
          where county.COUN_DM = '420000';
                    
          return countyId;
               
          End;
             
          function GETCUTTYPECODEBYID (CUTTYPEID In Numberreturn number as
             cutcode 
          number;
               
          Begin
                     
          select cuttype.CLAS_LXDM 
                   
          into cutcode  
                   
          from CF_CLASS cuttype 
                   
          where cuttype.CLAS_ID = cuttypeId;
                   
                   
          return cutcode; 
               
          End;
             
          function GETTREECODEBYID (TREEID In Numberreturn Varchar2 as
             treeCode 
          varchar2(50);
               
          Begin
                      
          select tr.TRSP_SZDM 
                    
          into treeCode
                    
          from GG_TREESPECIES tr
                    
          where tr.TRSP_ID = treeId;
                    
                    
          return treeCode;
               
          End;
             
          function GETFORESTCODEBYID (FID In Numberreturn number as
             lastNum 
          number;
              
          begin
                  
          select f.SOFO_LZDM into lastNum from GG_SORTSOFFOREST f where f.SOFO_ID = fId;
                 
          return lastNum;
              
          end;
          end COMMON_FUNCTION;
          /
          posted on 2009-05-21 14:35 王總兵 閱讀(418) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): DataBase
          主站蜘蛛池模板: 太原市| 南平市| 西盟| 马关县| 保康县| 库伦旗| 泰顺县| 周口市| 普格县| 合阳县| 瑞昌市| 阿拉善左旗| 庄河市| 梅河口市| 耿马| 康定县| 南城县| 泰宁县| 兴和县| 德江县| 郯城县| 济阳县| 锡林浩特市| 吴江市| 杂多县| 浦县| 大田县| 广安市| 福清市| 麻栗坡县| 宁远县| 肃北| 苏尼特右旗| 新巴尔虎左旗| 梧州市| 通江县| 咸阳市| 泸水县| 汉中市| 西畴县| 田林县|