If you use the APEX_JSON Package you can return CLOBS. The htp.p Package does not support CLOB output, if you want to use that you have to split the CLOB up into smaller Chunks of VARCHAR2.
Using the APEX_JSON Package is much more convenient, you can just pass a CLOB as a Parameter to the write procedure:
apex_json.open_object;
apex_json.write('mydata', MY_CLOB);
apex_json.close_object;
If you put that into an AJAX Callback Procedure on a Page and then use this Javascript to call it:
apex.server.process(
'MY_AJAX_PROCEDURE',
{},
{
success: function (pData) {
console.log(pData);
}
}
);
You will see your CLOB data in the console. You can also do everything else with it.
varchar2
; if the CLOB is larger than 32k it will give that error. You'll have to decide how you want to handle that - probably by breaking the value up into multiple lines? – Alex Poole