Wmsys. the function of wm_concat is to merge multiple rows into one row. For example, if A person buys three stocks A, B, and C, we will record three data records normally, now we want to display the stock of this person with a piece of data. This is wmsys. the wm_concat method is useful. However, in Oracle10G, the return value of this method can be directly converted to String for use, but in 11g it is Clob type, we must
Wmsys. the function of wm_concat is to merge multiple rows into one row. For example, if A person buys three stocks A, B, and C, we will record three data records normally, now we want to display the stock of this person with a piece of data. This is wmsys. the wm_concat method is useful. However, in Oracle 10g, the return value of this method can be directly converted to String for use, but in 11g it is Clob type, we must
Wmsys. the function of wm_concat is to merge multiple rows into one row. For example, if A person buys three stocks A, B, and C, we will record three data records normally, now we want to display the stock of this person with a piece of data. This is wmsys. the wm_concat method is useful.
However, in Oracle 10g, the return value of this method can be directly converted to String for use, but in 11g it is Clob type. We must convert clob to String or other types before using it.
/**
-
* Convert CLOB to String, static method
* @ Param clob Field
* @ Return content string. If an error occurs, null is returned.
*/
Public final static String clob2String (Clob clob ){
If (clob = null ){
Return null;
}
StringBuffer sb = new StringBuffer (65535); // 64 K
Reader clobStream = null; // create an input stream object
Try {
ClobStream = clob. getCharacterStream ();
Char [] B = new char [60000]; // obtain 60 K each time
Int I = 0;
While (I = clobStream. read (B ))! =-1 ){
Sb. append (B, 0, I );
}
}
Catch (Exception ex ){
Sb = null;
}
Finally {
Try {
If (clobStream! = Null)
ClobStream. close ();
}
Catch (Exception e ){
}
}
If (sb = null)
Return null;
Else
Return sb. toString ();
}