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?