The code below is take directly from example file ex11.sql
that comes with PL/JSON. All I added was the loop code for making the string larger because I wanted to test a true clob. It fails with certain lengths and I can't figure out why.
- 32,763 runs
- 32,764 fails
- 32,768 runs
- Results continue on like this.
- NOTE: Once you add the 8 extra hard coded json chars the true lengths for the above examples become: 32,771 (runs), 32,772 (fails), and 32,776 (runs).
Any ideas on how to get this to work consistently?
set serveroutput on;
declare
teststringlength pls_integer := 32763;
i pls_integer := 0;
obj json;
my_clob clob := '{"a":"';
begin
while i < teststringlength loop
my_clob := concat(my_clob,'X');
i := i + 1;
end loop;
my_clob := concat(my_clob,'"}');
obj := json(my_clob);
obj.print;
dbms_lob.trim(my_clob, 0); --empty the lob
obj.to_clob(my_clob);
dbms_output.put_line('----');
dbms_output.put_line(my_clob);
--example with temperary clob
my_clob := empty_clob();
dbms_lob.createtemporary(my_clob, true);
obj.to_clob(my_clob, true);
dbms_output.put_line('----');
dbms_output.put_line(my_clob);
dbms_lob.freetemporary(my_clob);
end;
/