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!

Pass value to and from a callback process

David BergerNov 1 2017 — edited Nov 6 2017

Hi, I need your help.

I would like to know how it is possible to pass a value (parameter) to a plsql callback process and how I can get a result back to javascript.

I have two text items (P_TEXT_IN, P_TEXT_OUT) and a button (BUTTON) and a test case:

var $wP;

var displayError = function(error) {

    console.error("Promise is rejected:", error);

};

var call_block1 = function() {

    $wP = apex.widget.waitPopup();

    return "End of Block 1";

};

var call_block2 = async function() {

    return apex.server.process( "MY_CALLBACK", {x01: "#P_TEXT_IN", pageItems: "#P_TEXT_IN"}, {refreshObject: "#P_TEXT_OUT"} );

};

var call_block3 = function() {

    $wP.remove();

    return "End of Block 3";

};

async function call_refresh() {   

    try {

        var result1 = await call_block1();

        console.log('Phase: ', result1);

        var result2 = await call_block2();

        console.log('Phase: End - Block 2');

        var result3 = await call_block3();

        console.log('Phase: ', result3);

    } catch(e) {

        $wP.remove();

        console.error(e);

        alert('Error!');

    } finally {

        console.log('Do something no matter what');

    }

};

call_refresh();

// Here I need the value of "v_result" from plsql....

The Callback Process "MY_CALLBACK":

DECLARE

   v_parameter_in   VARCHAR2(100);

   v_result         VARCHAR2(100);

BEGIN

  v_parameter_in := APEX_APPLICATION.G_X01;

  SELECT v_parameter_in || '-COMPLETED'

    INTO v_result

    FROM DUAL;

     -- This does not work... WHY?

  :P_TEXT_OUT := v_result;

    apex_json.open_object;

    apex_json.write('success', true);

    apex_json.write('v_result', v_result);

    apex_json.close_object;

END;

Question:

How can I get back the value of the variable "v_result" from my plsql?

Thanks in advance!

This post has been answered by David Berger on Nov 2 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 4 2017
Added on Nov 1 2017
11 comments
10,956 views