Solved

Display CLOB in web page

Posted on 2011-02-12
12
1,381 Views
Last Modified: 2012-05-11
Hi Experts,

We have a web page where in we display the records from table (one of cloumn is clob) using Oracle query

One of the particular record length is 73244 and its throwing exception
ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 73244, maximum: 4000)

We do not wish to truncate to 4000 characters using DBMS_LOB.SUBSTR function.

Is there any way to display the entire contents in SQL ? ( I cannot use PL/SQL as is web page query)

Thanks





0
Comment
Question by:ajexpert
12 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
What web language and what data provider are you using?
0
 
LVL 14

Author Comment

by:ajexpert
Comment Utility
When I execute the query in toad I get the error as I posted. Can u please help me how to convert clob column

there is no problem with data provider or web page. My goal is to modify query in suchh a way that I shouldn't get any error while executing from toad
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
Toad should handle CLOBs without a problem.  What is the query?  Are you trying to concatenate a clob with another string?
0
 
LVL 14

Author Comment

by:ajexpert
Comment Utility
No I am not trying to concatenate with other string

yes toad can handle clobs but I m not able to see data, so we use TO_CHAR funtion. Since the data is more than 4000 characters it is throwing error as I stated above
0
 

Expert Comment

by:Suriyaraj_Sudalaiappan
Comment Utility
Plz try to convert by use of TO_CLOB function
0
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 400 total points
Comment Utility
You can only use to_clob when inserting a long into a new table.

As you already know, you cannot use to_char on a clob this way is it is larger than 4000 character.

You have me confused.  To can or cannot select the native clob in toad?  I assume that you can and the problem is with native clobs with the web page.

If this is correct, I need to know the web language and data provider.

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 5

Assisted Solution

by:Sanjeev Labh
Sanjeev Labh earned 100 total points
Comment Utility
Hi I am also a little perplexed here since as far as I know toad can easily handle and display any clob coloumn being selected in a query.
e.g.

select my_clob from my_tab

toad returns the column data in the result row you would find an ellipse (...) symbol. Once you click it the whole text window opens with the clob data. So, it is really quite simple in toad. I am not sure if you are doing the same or I have got your question wrongly.
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
sanjeevlabh,

The issue was with using to_char on the clob from toad and the web code.  That is what generates the error.

We need to know what the web app was developed with so we can get that code to handle native clobs without trying to convert it to a string.

0
 
LVL 3

Expert Comment

by:dbauermann
Comment Utility
ajexpert,

If you are using owa packages, I suggest the following code:

(...)
v_image   blob;
v_buffer   RAW(32767);
v_offset   BINARY_INTEGER := 1;
v_buffer_size   NUMBER := 32767;
(...)
OWA_UTIL.MIME_HEADER('image/gif');
 -- read the LOB content in a loop and send it across to the browser
LOOP
   DBMS_LOB.READ(v_image, v_buffer_size, v_offset, v_buffer);
   -- convert the raw content read into varchar2 and send it to the browser
   htp.prn(UTL_RAW.CAST_TO_VARCHAR2(v_buffer));
   v_offset:= (v_offset + v_tamanho_buffer);
END LOOP;
(...)

Open in new window

0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
>>If you are using owa packages, I suggest the following code:

That code is for a BLOB. not a CLOB.

0
 
LVL 14

Author Comment

by:ajexpert
Comment Utility
@slightwv:

We are using java - provider jdbc for oracle

I spoke to my team member letting him know that he needs to write a routine to display CLOB from db

Thanks
0
 
LVL 76

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 400 total points
Comment Utility
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

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

763 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

7 Experts available now in Live!

Get 1:1 Help Now