/** * @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 ;