/*** @title: clobparsestring * @description: TODO Clob Object converted to String *@author: Yubo *@paramCLOB *@return * @throwsSQLException * @date: 2016-1-6 pm 4:01:42*/ Public StaticString clobparsestring (Clob Clob)throwssqlexception{String Result= ""; if(Clob! =NULL) {result= Clob.getsubstring ((Long) 1, (int) clob.length ()); } returnresult; }
Row to column Oracle:
Create or ReplaceType Type_concatstr_clob asobject (Total Clob, staticfunctionOdciaggregateinitialize (sctxinchOut Type_concatstr_clob)return Number, memberfunctionOdciaggregateiterate (selfinchOut Type_concatstr_clob,valueinchClobreturn Number, memberfunctionOdciaggregateterminate (selfinchType_concatstr_clob,returnvalue out Clob,flagsinch Number)return Number, memberfunctionOdciaggregatemerge (selfinchOut TYPE_CONCATSTR_CLOB,CTX2inchTYPE_CONCATSTR_CLOB)return Number)/Create or Replacetype body Type_concatstr_clob is --rewrite on the basis of CONCATSTRStaticfunctionOdciaggregateinitialize (sctxinchOut Type_concatstr_clob)return Number is beginSctx:=Type_concatstr_clob (NULL); returnodciconst.success; End; MemberfunctionOdciaggregateiterate (selfinchOut Type_concatstr_clob,valueinchClobreturn Number is beginself.total:=Self.total|| ',' ||value; returnodciconst.success; End; MemberfunctionOdciaggregateterminate (selfinchType_concatstr_clob,returnvalue out Clob,flagsinch Number)return Number is beginreturnvalue:= LTrim(Self.total,','); returnodciconst.success; End; MemberfunctionOdciaggregatemerge (selfinchOut TYPE_CONCATSTR_CLOB,CTX2inchTYPE_CONCATSTR_CLOB)return Number is beginself.total:=Self.total||Ctx2.total; returnodciconst.success; End;End;/
Create or Replace function varchar2 return clob parallel_enable aggregate using Type_concatstr_clob;
For example:
SELECT from (SELECT f_concatstr_clob (e.c_agencyno| | ' : ' || from Tagencyinfo e) U;
Clob object is converted to string