[Last Call] Learn how to a build a cloud-first strategyRegister Now


How to get the Length or size of the clob?

Posted on 2001-07-03
Medium Priority
Last Modified: 2012-08-14
How can I change this code so its gets the size of the CLOB? Currently I get the length of the buffer and it prints is 4 times.  But I need to get the size of the CLOB to WRITE it!

What should I use?

       l_clobWriter.write(l_buffer,0,l_buffer.length);   // Write to Clob

Here's the entire code.....

public void writeStringToClob(int i_issue_id, String s_description) {

 Connection   x_conn = (Connection) ox_pool.checkout ();
 Statement    x_stmt = null;
 s_description = "TEST THE 4000 character limit";

cdebug.println ("\n\nTESTING:  " + s_description);

    try {
           x_stmt = x_conn.createStatement();
//        cdebug.println("x_statment: " + x_stmt.toString());

      ResultSet  l_lobDetails = x_stmt.executeQuery(
          "SELECT DESCR FROM ISSUE WHERE ISSUEID="+ Integer.toString ( i_issue_id ) + " FOR UPDATE");
        // load the rest of the description into the Clob Column

        if ( l_lobDetails.next() )

        Clob l_clobDescr = l_lobDetails.getClob(1);
        Writer l_clobWriter = ( (oracle.sql.CLOB)l_clobDescr).getCharacterOutputStream();
          cdebug.println ("TESTING GET CLOB:  " + l_lobDetails.getClob(1));

//        java.io.Reader l_clobStream = l_clobDescr.getCharacterStream();

        //Read from Char Stream and  write to Clob Stream
        char[] l_buffer = new char[10*1024];  // buffer holding the characters being transferred
           l_buffer = s_description.toCharArray();
        for (int i = 0; i<l_buffer.length; i++){   // Read from StringBuffer
            cdebug.println (" GOT BUFFER: " + l_buffer[i]);
            l_clobWriter.write(l_buffer,0,l_buffer.length);   // Write to Clob

            //cdebug.println ("Result: " + l_clobDescr);

//        l_clobStream.close();  // close reader
        l_clobWriter.close();  // close writer

           l_lobDetails.close();  // close resultset
        x_stmt.close();        // close statement
        x_conn.close();        // close connection

        } catch (Exception ex) {
           cdebug.println ( "GtsNewIssue writeStringToClob caught error in getting the String");
           cdebug.println ("GtsNewIssue caught error: " + ex.toString() );

ox_pool.checkin ( x_conn );

Question by:sdesar
  • 3
  • 2

Accepted Solution

srikant033100 earned 40 total points
ID: 6251399
SQL>  create table abc (a number,b clob);

Table created.

SQL> insert into abc values(1,'abcdefg');

1 row created.

SQL> commit;

select dbms_lob.getlength(b) from abc;



Please increase the points


Author Comment

ID: 6257058
i know how to get the length as you describe above.

What I need is how should I use the READER to
read the string and allocate the length.
Because with the code above - the string gets repeated upto 32k.

Any suggestions please!

PS .. I will increase the points!

Expert Comment

ID: 6331937
It's time to clean up this topic area and that means taking care of this question. Your options at this point are:
1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.
2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.
3.  Ask Community Support to help split points between participating experts.  Just comment here with details.
4.  Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.
If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there.  We also request that you review any other open questions you might have and update/close them.  Display all your question history from your Member Profile to view details.
Hi Experts:
In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.
Experts, please do not add further "answer" information to this question.  I will be back in about one week to finalize this question.
Thank you everyone.
Moondancer :)
Community Support Moderator @ Experts Exchange
P.S.  Engineering has been advised about the error in the comment date/time sort order.
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!


Expert Comment

ID: 6345406
If this proposed answer did not serve your needs, then reject it with comments as to what else is needed so the question returns to the Open Question queue where more experts are likely to step in and help you.  Please also update/finalize your other open questions.

thank you,

Community Support Moderator @ Experts Exchange

Author Comment

ID: 6346137

Expert Comment

ID: 6346154
Thank you very much, sdesar, for returning and finalizing this in grand style.
Community Support Moderator @ Experts Exchange

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question