How to get the Length or size of the clob?

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_conn.setAutoCommit(false);
           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 );
}

sdesarAsked:
Who is Participating?
 
srikant033100Connect With a Mentor Commented:
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;

DBMS_LOB.GETLENGTH(B)
---------------------
                    7

SQL>

Please increase the points

0
 
sdesarAuthor Commented:
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!
Thanks
0
 
MoondancerCommented:
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.
 
PLEASE DO NOT AWARD THE POINTS TO ME.
 
____________________________________________
 
 
 
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.
0
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.

 
MoondancerCommented:
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,

Moondancer
Community Support Moderator @ Experts Exchange
0
 
sdesarAuthor Commented:
thx
0
 
MoondancerCommented:
Thank you very much, sdesar, for returning and finalizing this in grand style.
Moondancer
Community Support Moderator @ Experts Exchange
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.