zoukankan      html  css  js  c++  java
  • Clob对象转换为String

      /**
         * @title: clobParseString
         * @description:TODO Clob对象转换为String
         * @author: yubo  
         * @param clob
         * @return
         * @throws SQLException
         * @date:2016-1-6下午4:01:42
         */
        public static String clobParseString(Clob clob) throws SQLException{
            String result = "";
            if(clob != null){
                result = clob.getSubString((long)1,(int)clob.length());
            }
            return result;
        }

     行转列oracle:

    create or replace type type_concatstr_clob as object
    (
      total  clob,
      static function ODCIAggregateInitialize(sctx IN OUT type_concatstr_clob) return number,
      member function ODCIAggregateIterate(self IN OUT type_concatstr_clob,value IN clob) return number,
      member function ODCIAggregateTerminate(self IN type_concatstr_clob,returnValue OUT clob,flags IN number) return number,
      member function ODCIAggregateMerge(self IN OUT type_concatstr_clob,ctx2 IN type_concatstr_clob) return number
    )
    /
    
    create or replace type body type_concatstr_clob
    is
      --在concatstr的基础上改写
      static function ODCIAggregateInitialize(sctx IN OUT type_concatstr_clob) return number
      is
      begin
        sctx := type_concatstr_clob(null);
        return ODCIConst.Success;
      end;
    
      member function ODCIAggregateIterate(self IN OUT type_concatstr_clob,value IN clob) return number
      is
      begin
        self.total := self.total || ',' || value;
        return ODCIConst.Success;
      end;
    
      member function ODCIAggregateTerminate(self IN type_concatstr_clob,returnValue OUT clob,flags IN number) return number
      is
      begin
        returnValue := ltrim(self.total,',');
        return ODCIConst.Success;
      end;
    
      member function ODCIAggregateMerge(self IN OUT type_concatstr_clob,ctx2 IN type_concatstr_clob) return number
      is
      begin
        self.total := self.total || ctx2.total;
        return ODCIConst.Success;
      end;
    end;
    /
    create or replace function f_concatstr_clob(input varchar2) return clob
      parallel_enable
      aggregate using type_concatstr_clob;

    For example:

    SELECT u.c_agencyname FROM (
    SELECT f_concatstr_clob(e.c_agencyno||':'||e.c_agencyname) c_agencyname FROM   tagencyinfo e) u ;
  • 相关阅读:
    @RequestParam和@PathVariable用法小结
    Spring 的监听事件 ApplicationListener 和 ApplicationEvent 用法
    allator 对springBoot进行加密
    commons-lang3相关类实例
    JSP自定义标签
    Netty的简单Demo
    Spring-AOP为类增加新的功能
    深入理解abstract class和interface
    linux的基本操作
    GitHub从小白到熟悉<二>
  • 原文地址:https://www.cnblogs.com/Lightning-Kid/p/5106118.html
Copyright © 2011-2022 走看看