|
Re: PLS-00172: string literal too long while passing large XML as input to a procedure [message #690040 is a reply to message #690039] |
Mon, 23 September 2024 10:10 |
|
Michel Cadot
Messages: 68728 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
1/ If you want where the comes from from, first remove WHEN OTHERS clause. Read WHEN OTHERS.
2/ From what you posted, the error comes from the PL/SQL you attached and not the procedure:
SQL> DECLARE
2 l_output_value VARCHAR2(100);
3 l_xml_data clob := '
4
5 <root>
6 <items>
7 <item>
8 <name>Item 1</name>
9 <description>This is a detailed d
...
344 </item>
345 <!-- Repeat as needed to reach 5000 characters -->
346 </items>
347 </root>
348 ';
349
350 BEGIN
351
352 process_large_xml1(l_xml_data, l_output_value);
353
354 DBMS_OUTPUT.PUT_LINE (l_output_value);
355
356 END;
357 /
l_xml_data clob := '
*
ERROR at line 3:
ORA-06550: line 3, column 20:
PLS-00172: string literal too long
Split the string into several substrings like 'xxx'||'yyy'||'zzz'...
[Updated on: Mon, 23 September 2024 10:11] Report message to a moderator
|
|
|
Re: PLS-00172: string literal too long while passing large XML as input to a procedure [message #690041 is a reply to message #690039] |
Mon, 23 September 2024 10:13 |
cookiemonster
Messages: 13961 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
clobs will happily take longer values than 4,000 characters (not 40,000), that's why they exist.
String literals - any hardcoded value in quotes - won't.
So your error is due to the amount of data inside those quotes.
You get around the issue by breaking the string literal down into chunks that are 4000 characters or less and then concatenating them into the clob variable:
DECLARE
l_output_value VARCHAR2(100);
l_xml_data clob;
BEGIN
l_xml_data := to_clob('<first 4000 characters>');
l_xml_data := l_xml_data || '<next 4000 characters>');
<repeat until you have everything>
process_large_xml1(l_xml_data, l_output_value);
DBMS_OUTPUT.PUT_LINE (l_output_value);
END;
/
That'll make your anonymous block work.
It probably won't help with any issue with the front end code.
|
|
|
|
|
|