I am using oracle verion 10. There is stored procedure in PL/SQL using varchar2 variable. The code is constantly appending the varchar2 variable. When the varchar2 variable size exceeds 32767, it cannot append any more value. Now I want to change the data type to long or clob(in order to accomodate more characters), it does not work. How to modify the code here to have the same appending functionality with clob or long?
sample appending x:= x || 'mydata';
The
long
datatype is deprecated; if you can you should seriously consider migrating yourlong
column to aclob
.If you were working with a
clob
you could append past the 32kvarchar2
limit like this:You can append to a
long
with the concatenate operator||
, but as you've seen already, only up to 32k. There is no easy way to handlelong
values above that within PL/SQL. You might be able to do soemthing withdbms_sql
but it's really not going to be worth the effort if there is any possiblility of switching the table column to aclob
.If you want to pass the clob back to the caller, and it's a temporary clob, it will have to be defined by the caller and be passed it after it's created:
Otherwise the object won't exist as far as the caller is concerned.
If the
clob
exists - selected from a table, say, so you don't need thecreatetemporary
call - then you can just assign it to anout
parameter, but I don't think that's the case for what you've described.