3

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;
/

enter image description here

gfrobenius
  • 3,987
  • 8
  • 34
  • 66
  • It looks like it's a problem `JSON_PRINTER.llcheck()`, which is a private function using global variables. I would guess you're hitting some funny behaviour dependent on specific values of `max_line_len` and/or `cur_line_len` .Which probably means you've got a session of low-level debugging ahead of you ;) – APC Dec 22 '14 at 20:14

0 Answers0