Different return values of a function wmsys. wm_concat in Oracle10g and 11g

Source: Internet
Author: User
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 ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.