Calling an Oracle Function Through Ajax in Place Verification Objectives in Oracle APEX v4.2.2

I am using Oracle 11g with Oracle Apex v4.2.2, and I was wondering what is the best way to call an Oracle function through an ajax call in a dynamic action.

I basically have a function that takes six parameters that either return the result "INVALID" or "VALID".

In my page, I want to be able to accept the values ​​entered by the user, and as soon as they press the button for processing, I need to check through ajax whether the result was "INVALID" or "VALID" and immediately the user with a dialog box notifies them that that an error has occurred.

Is there a new way to handle this type of ajax request to call a function in Oracle APEX v4.2.2?

Any help / links to examples to achieve the above would be great.

Thank.

+1
source share
1 answer

Ajax + apex 4.2 = apex.server.process api
This requires that you have a process at the process point at the request of the page or in the application process. In this case, you must call your function and specify parameters that may be page elements. To provide a return, enter the values ​​in the http buffer with calls htp.p.

DECLARE
  some_var1 VARCHAR2(50);
BEGIN
  some_var1 := my_package.my_function(:P1_EMPNO, :P1_DEPTNO);
  -- write values back
  htp.p(some_var1);
END;

apex.server.process . - javascript.
: dataType JSON, , , json, . , , INVALID, !

apex.server.process ( "MY_PROCESS", {
  pageItems: "#P1_DEPTNO,#P1_EMPNO"
  }, {
    dataType: "text"
  , success: function( pData ) { 
      //pData should contain VALID or INVALID - alert it
      alert(pData);
      if ( pData === 'INVALID' ) {
        // do something here when the result is invalid
        // maybe you want to color something red for example
        alert('The data you have entered is invalid');
      };
    }
  } );

, , . PLSQL- , , , .
, , , . execute javascript ajax- .

+3

All Articles