Solved

How to get the Length or size of the clob?

Posted on 2001-07-03
6
800 Views
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_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 );
}

0
Comment
Question by:sdesar
[X]
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
6 Comments
 
LVL 4

Accepted Solution

by:
srikant033100 earned 10 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;

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

SQL>

Please increase the points

0
 

Author Comment

by:sdesar
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!
Thanks
0
 
LVL 1

Expert Comment

by:Moondancer
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.
 
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:Moondancer
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,

Moondancer
Community Support Moderator @ Experts Exchange
0
 

Author Comment

by:sdesar
ID: 6346137
thx
0
 
LVL 1

Expert Comment

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

705 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