2

What is the scope of the apex global variables APEX_APPLICATION.G_X01...G_X10? Are they truly 'global', session-scoped or request-scoped?

I did some tests and my findings seem to be that these global variables are request-scoped (ie: other requests in the same session and other requests in different sessions get their own copies of the global variables), but I'd like to confirm my findings are correct.

Details of our setup:

client-side JS code looks like this:

data = {'first_name':$('#P25_FIRST_NAME').val()};
data = JSON.stringify(data);

$.ajax({
   type: "POST",
   url: "wwv_flow.show",
   data: {
     p_flow_id:$('#pFlowId').val(), 
     p_flow_step_id:$('#pFlowStepId').val(), 
     p_instance:$('#pInstance').val(), 
     x01:data,
     p_request:"APPLICATION_PROCESS=AJAX_TEST"
   },
   dataType: "json",
   success: function(data) {
     alert('success:\n' + data);
   },
   error: function(data) {
     alert('error:\n' + data);
   },
});

server-side PL/SQL code looks like this:

CREATE OR REPLACE PROCEDURE
AJAX_TEST IS

JSON_REQUEST JSON;
JSON_RESPONSE JSON;

BEGIN

  JSON_REQUEST := JSON(APEX_APPLICATION.G_X01);
  JSON_RESPONSE := JSON();

  JSON_RESPONSE.PUT('first_name', JSON_REQUEST.GET('first_name').GET_STRING());
  JSON_RESPONSE.PUT('last_name', 'smith');

  HTP.P(JSON_RESPONSE.to_char());

END AJAX_TEST;

I want to be sure that the variables APEX_APPLICATION.G_X01, X02, etc...won't be affected by other requests within the scope of processing the current request.

Thanks much!

1 Answer 1

1

Per request (or page submission). A quick test can confirm this:
On Demand Process:"bogus"

htp.p("X01: '||apex_application.g_x01);

Then run from the console:

var ajaxRequest = new htmldb_Get(null, $v("pFlowId"), "APPLICATION_PROCESS=bogus", $v("pFlowStepId"));
ajaxRequest.addParam("x01","xxxx");
var ajaxReturn = ajaxRequest.get();

RESPONSE:

X01: xxxx

And then run:

var ajaxRequest = new htmldb_Get(null, $v("pFlowId"), "APPLICATION_PROCESS=bogus", $v("pFlowStepId"));
var ajaxReturn = ajaxRequest.get();

RESPONSE:

X01: 

Of course, during a page submit the f## arrays and x## items will hold the submitted value until the end of the processing.
Also, another user (session) won't affect the values. You could probably say that these item's cache is cleared after each submit/request.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, that definitely confirms it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.