Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Clob length issue

sadasivamJul 30 2021

I have below ananymous block giving error
DECLARE
V_P_ENCODED_CONTENT CLOB;
BEGIN
V_P_ENCODED_CONTENT :='35 thousand length string';
END;
PLS-00172: string literal too long
After modify to below its working as just adding pipe to spli the string,
V_P_ENCODED_CONTENT :='32 thousand length'||'3000 length string';
So for achieving this in my program i am trying the sample code like below,but its not giving the complte result.I need to add '|| operators in my string each 50 charecter length.Can you please help me on this.
declare
V_Column_Value Clob;
v_Column_Value_tmp Clob;
Begin
v_Column_Value :='111111111122222222222333333333344444444445555555555111111111122222222222333333333344444444445555555555';
dbms_output.Put_line('Length(v_Column_Value)='||Length(v_Column_Value));
If Length(v_Column_Value) > 50 Then
v_Column_Value_tmp := v_Column_Value;
v_Column_Value := Null;
For L In( select substr(v_Column_Value_tmp, (level-1)*50+1, 50) chnk
from Dual
connect by level <= length(v_Column_Value_tmp)/50 )
Loop
If v_Column_Value Is Null Then
v_Column_Value := L.chnk;
Else
v_Column_Value := v_Column_Value||chr(39)||'||'||chr(39)||L.chnk;
End If;
End Loop;
Dbms_Output.Put_Line('after Length(v_Column_Value)='||Length(v_Column_Value));
Dbms_Output.Put_Line(v_Column_Value_tmp);
Dbms_Output.Put_Line(v_Column_Value);
End If;
End;

This post has been answered by Frank Kulash on Jul 31 2021
Jump to Answer
Comments
Post Details
Added on Jul 30 2021
5 comments
94 views