Solved

Display CLOB in web page

Posted on 2011-02-12
12
1,466 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
[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
12 Comments
 
LVL 77

Expert Comment

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

Author Comment

by:ajexpert
ID: 34880861
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 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34880996
Toad should handle CLOBs without a problem.  What is the query?  Are you trying to concatenate a clob with another string?
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 14

Author Comment

by:ajexpert
ID: 34881137
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
ID: 34881763
Plz try to convert by use of TO_CLOB function
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 400 total points
ID: 34883419
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
 
LVL 5

Assisted Solution

by:Sanjeev Labh
Sanjeev Labh earned 100 total points
ID: 34884038
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 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34884533
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
ID: 34886925
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 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34887592
>>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
ID: 34889164
@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 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 400 total points
ID: 34889219
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

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…
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 videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

630 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