[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register 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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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.
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.


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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

656 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