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 string operations cause ORA-06502 "buffer too small" error

cilyrikJun 3 2020 — edited Jun 4 2020

Tech details (db version, etc.) in tags.

Trying to run a PL/SQL script that should print a returned result of a function which is CLOB:

declare

     l_clob clob;

    v_clob_chunk varchar2(32767);

begin

     DBMS_LOB.createtemporary(l_clob, true);

     DBMS_LOB.open(l_clob, open_mode => DBMS_LOB.lob_readwrite);

     DBMS_LOB.append(dest_lob => l_clob, src_lob => rec_mgr.render(arg_n_rec => 1));

-- rec_mgr.render is a function that returns a CLOB with an HTML rendered from data in a record with ID = 1 from table REC

     DBMS_OUTPUT.put_line(l_clob); -- this works fine

     htp.print(l_clob); -- this causes ORA-06502: PL/SQL: numeric or value error: character string buffer too small

     v_clob_chunk := substr(l_clob, 1, 32767); -- this also causes ORA-06502: PL/SQL: numeric or value error: character string buffer too small

end;

Obviously I run line 10 and line 11 interchangeably (commenting one while running the other).

What should I do to fix it?

This post has been answered by Solomon Yakobson on Jun 3 2020
Jump to Answer
Comments
Post Details
Added on Jun 3 2020
15 comments
8,306 views