Skip to Main Content

APEX

APEX - apex.server.process pass clob to client

PJFeb 18 2022 — edited Feb 23 2022

ISSUE: I am using javascript (jsPdf) to produce a PDF report on the client - and the data is passed from the DB as a json string. All works fine - unless the data exceeds 32k. How do I pass the clob to the client?

Here is the relevent code:
Within the js file ..

apex.server.process(
   'Generate', {
       x01: apex.item("P9001_SUBSCRIBER_ID").getValue(),
       x02: apex.item("P9001_REQUESTER_NAME").getValue(),
       x03: apex.item("P9001_SUBJECT_FILE_ID").getValue(),
   }, {
       success: function(result) {
         displayLog('start', 'result', result);
         console.log(result)
         printPdf(result);
       },
       error: function(error) {
           console.log('error');
           console.log(error);
       },
       dataType: 'json',
       async: false
   });
};

The process Generate (simplified):

declare
  l_data clob;
  l_subscriber_id integer             := APEX_APPLICATION.G_X01;
  l_requestor_username varchar2(4000) := APEX_APPLICATION.G_X02;
  l_subject_file_id  integer          := APEX_APPLICATION.G_X03;
  l_subject_file_type_code   varchar2(16);
  l_report_name              varchar2(64);

begin
  plj_lg.push('APEX-1203:9001','PDFReport');
  l_report_name := 'TestReport';
  plj_lg.d('Report running: '|| l_report_name);
    
  l_data := APX_CDD.REPORT_DATA_AS_JSON (
                              p_report_name        => l_report_name,
                              p_subscriber_id      => :G_SUBSCRIBER_ID,
                              p_requestor_username => lower(plj_auth.get_current_user), 
                              p_subject_file_id    => :P0_SUBJECT_FILE_ID,
                              p_module_id          => :P0_MODULE_ID,
                              p_report_version     => '1.0');
  
  htp.p(l_data);
  
  plj_lg.d('Report complete.  Clob size: '|| dbms_lob.getlength(l_data) );
  plj_lg.pop;
  
exception
    when others then
      htp.p(l_data);
      plj_err.handle();
end;

HTP.P has a limit of 32K -1 bytes
How do in out a clob to js?
The error from the console:

promise: function promise(e)​
readyState: 4
​
responseText: "sqlerrm:ORA-06502: PL/SQL: numeric or value error\n"

Thank you

This post has been answered by PJ on Feb 23 2022
Jump to Answer
Comments
Post Details
Added on Feb 18 2022
1 comment
456 views