隨筆 - 100  文章 - 50  trackbacks - 0
          <2025年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          收藏夾

          我收藏的一些文章!

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          在Oracle中,sql中in不能超過1000個,比如:select  * from table  t where t.id in (1,2,3,......1001,1002)
          系統將報錯,解決辦法如下,寫成兩個或者多個。如:t.id in (1,2,....1000) or t.id in (1001,1002)
          實現代碼如下:
           public String DivString(){
            StringBuffer sb = new StringBuffer();
            StringBuffer sb2 = new StringBuffer();
            List agentList = new ArrayList();
            for(int i =0;i<1100;i++) 
             agentList.add(i);
            for(int i=0;i<agentList.size();i++){
             if(i==agentList.size()-1)
              sb.append("'").append(agentList.get(i)).append("')");
             else if(i%1000==0&&i>0)
              sb.append("'").append(agentList.get(i)).append("'")
              .append(") or t.id in (");
             else
              sb.append("'").append(agentList.get(i)).append("',");
            }
            sb2.append(" t.id  in ('',"+sb);
            System.out.println("sql is: "+sb2.toString());
            return sb2.toString();
           }
          posted on 2010-01-11 22:48 fly 閱讀(3313) 評論(2)  編輯  收藏 所屬分類: 數據庫學習

          FeedBack:
          # re: oracle sql in中數據不能超過1000個的解決方法。 2010-08-20 21:10 
          你這個方法都不行,不要抄了,以后  回復  更多評論
            
          # re: oracle sql in中數據不能超過1000個的解決方法。 2011-08-03 09:52 幽野閑鶴
          查多次不久完了,in效率那么低.查多次效率比in高多了
            回復  更多評論
            
          主站蜘蛛池模板: 常熟市| 达孜县| 永济市| 衢州市| 五指山市| 三台县| 阜平县| 永清县| 海原县| 花莲县| 阿坝县| 云霄县| 兴安盟| 临夏市| 分宜县| 沙田区| 天水市| 长泰县| 山阳县| 永济市| 昌邑市| 临猗县| 平度市| 葫芦岛市| 定安县| 轮台县| 石柱| 健康| 冀州市| 司法| 鄯善县| 玛曲县| 龙胜| 宁陕县| 扶风县| 临高县| 曲阜市| 肥乡县| 汉阴县| 山东省| 东城区|