Solved

Use of CLOB in PL/SQL

Posted on 2009-04-07
6
730 Views
Last Modified: 2013-12-07
I have an unknown length of characters to store. Hence, I opted to use CLOB in my PL/SQL.

My statements are quite simple:
msg CLOB;
BEGIN
loop
...
...... msg := msg || 'more text';
...
end loop;
END;

I got a ORA-6502 numeric value error - host bind array too small. I checked the size of the variable at the time was only about 200 bytes.

1) what am I doing wrong?
2) Is there a solution without involving a CAST statement?
3) does CLOB take up unused space when the actual size of the content is small?

any leads or help is appreciated. Thanks in advance.

0
Comment
Question by:New2Oracle
[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
  • 3
6 Comments
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 100 total points
ID: 24090909
can you post more of your code?
or a minimal test case that reproduces the error?
0
 

Accepted Solution

by:
New2Oracle earned 0 total points
ID: 24091525
Other codes in my mind is indifferent but here it goes anyway. could the chr(10) has any effect on the CLOB variable?, e.g. implicitly converted the field into another data type?

Thanks in advance for the help.

declare
msg clob;
cnt number;
Begin
cnt := 0;
for i in (select * from table) loop
  cnt := cnt + 1;
   msg := msg ||' this is record '||cnt||chr(10);
end loop;
dbms_output.put_line(msg);
end;
0
 

Author Comment

by:New2Oracle
ID: 24091675
SORRY FOLKS! a foolish mistake on my part.

the error message was raised when I tried to dbms_output.put_line on a CLOB variable. By reiterating the code to sdstuber, I found my own foolish mistake.

thanks to all who looked at this problem.
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:New2Oracle
ID: 24091704
Thanks to all.
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 24091718
glad I could help, even if indirectly
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 24091744
I will note though,  once I substituted a real object instead of just "table"  in your loop your code ran fine for me.  

dbms_output.put_line was able to be printed a clob just fine until the clob  exceeds 32K (the varchar2 limit)

0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

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 video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

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