使用wm_concat函數導致字符串過長


場景:使用select wm_concat(xxxxx) from table 的時候 返回的字符串過長 

解決方案 :使用to_clob 將字符串轉成 clob類型,但是由於使用的前端框架不能解析clob類型的值

      再將clob轉化成String類型 

      

List<Map> olists=oDao.queryOrgRoleInfo(query);
        for(Map omap :olists ){
            try {
                omap.put("ORGNAME", ClobToString((Clob)omap.get("ORGNAME")));
            } catch (SQLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
 public String ClobToString(Clob clob) throws SQLException, IOException {
          
           String reString = "";
               if (clob == null){
               return "";
               }
            Reader is = clob.getCharacterStream();// 得到流
            BufferedReader br = new BufferedReader(is);
            String s = br.readLine();
            StringBuffer sb = new StringBuffer();
            while (s != null) {// 執行循環將字符串全部取出付值給StringBuffer由StringBuffer轉成STRING
             sb.append(s);
             s = br.readLine();
            }
            reString = sb.toString();
            return reString;
          }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM