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!

sys_context not working from APEX application / environment

731104Jan 24 2012 — edited Jan 25 2012
I am struggling to retrieve a user-defined context value using sys_context(...) from APEX application / environment

I have created a global context to be used as a storage mechanism for log severity to be recorded.
 CREATE OR REPLACE CONTEXT PA_LOGGER_CTX USING PA_LOGGER ACCESSED GLOBALLY;
It is seeded through a function pa_logger.set_severity(1) within the package pa_logger through (excerpt):
  dbms_session.set_context(c_ctx_context_label, c_ctx_severity_label, TO_CHAR(p_severity_in));

  with:
  c_ctx_context_label     CONSTANT NVARCHAR2(16) := 'PA_LOGGER_CTX';
  c_ctx_severity_label    CONSTANT NVARCHAR2(8) := 'SEVERITY';
  p_severity_in   IN  PLS_INTEGER
using the following from sqlplus, other DB-tools, works as expected:
-- setting it
BEGIN
  pa_logger.set_severity(2);
END;
-- displaying it
SELECT sys_context('PA_LOGGER_CTX', 'SEVERITY') FROM DUAL;
returns 2

This works from different sessions, different users ... no problem.

Using it from within an APEX (accessed via embedded gateway/XE11.2 or OHS/11.2.0.2.0 ) application or even from the "SQL Commands" from the APEX Workspace returns a NULL value for :
SELECT sys_context('PA_LOGGER_CTX', 'SEVERITY') FROM DUAL;
And
   SELECT value  FROM GLOBAL_CONTEXT WHERE NAMESPACE='PA_LOGGER_CTX' and ATTRIBUTE = 'SEVERITY';
returns the right value, which obviously defies the purpose of using the CONTEXT.
It is as well possible to set the CONTEXT to a different value, which is picked up outside APEX, but even so using sys_context does not work, always returning NULL

As a note aside: using sys_context with a standard CONTEXT, e.g. SELECT sys_context('USERENV', 'NLS_DATE_FORMAT') from DUAL works without any problems.


I guess I have a conceptual break somewhere. Does this have to do with the APEX user used, wrapping within the APEX environment, the way the context is defined ....

Any help is appreciated.

Many thanks,
- Thomas
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 22 2012
Added on Jan 24 2012
4 comments
3,073 views