Solved

How to get the Length or size of the clob?

Posted on 2001-07-03
6
795 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
  • 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

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…
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…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to take different types of Oracle backups using RMAN.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now