Skip to Main Content

APEX

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!

How to catch errors in an AJAX call when calling an on-demand pl/sql process

I have a page in an APEX 19.2 application that allows users to upload an xlsx file via a drag and drop plugin and load the data and validate the data.  However, when an error in the data is encountered either in the loading or the validation process (both pl/sql processes) I am having a hard time getting the error to be passed back to the calling ajax process.

code is below:

Code is a dynamic action call on a button click..

/* Show a processing image */

var lSpinner$ = apex.util.showSpinner();

var l_Batch_id;

var l_Status;

var l_Error;

/* Here I am calling the on demand page process to load & validate data from the uploaded xlsx file

apex.server.process("VALIDATE_DATA", {

  x01: $v('P255_HEADER_ID'),

  x02: $v('P255_LOAD_SEQ'),

  x03: $v('P255_UPLOAD_STATUS'),

  x04: $v('P255_ERROR') 

}, {

  //pageItems: ''  

  // dataType: 'text'  

}).done(function(pData) {

   

  console.log("Calling DB OVer - " + pData);

  

  // you can loop JSON key and values

  $.each(pData, function(key, val) {

   

    console.log(key + " : " + val);

  });

   

  // Just do something with return values

/* items I am using to populate page items with returned values on demand process

  l_batch_id = pData.batch_id;

  l_Status   = pData.status;

  l_Error    = pData.error;

   

}).always(function() {

   

  /* Remove the processing image */

  lSpinner$.remove();

  hideRegion('#load_data');

         apex.region('igrid').refresh(); 

   

  showRegion('#xlsx-button');   

   

  if ( (l_Status == "ERROR") || (l_Status == null) )

     {

       showRegion('#message-error');

        

     }

    else

      {

       showRegion('#save-data');

       showRegion('#summary');

       apex.region('summary').refresh();

    

      }

   

  // code that needs to run for both success and failure cases 

});

The issue I have run into started with a previously posted error of excel xlsx files not storing certain numeric values properly and when the wwv_flow_data_parser.parse function encounters a  .07 value it returns it as 7.0000000000000007E-2 which is longer than expected (expectung up to 20 characters returned and getting 22 back).  the overflow error is never caught and returned to the ajax call.  I am using a started exception handling block in the pl/sql procedure called by the on demand process but no errors get logged.

Can anyone offer me a hand in trying to resolve this issue?

Thank you,

Tony Miller

Los Alamos, NM

Comments
Post Details
Added on Jun 19 2020
0 comments
1,042 views