ORA_END_USER_CONTEXT

Purpose

Use ORA_END_USER_CONTEXT operator to refer to a context attribute as a variable (or expression). You can retrieve the following:

Prerequisites

Calling ORA_END_USER_CONTEXT operator to access the pre-defined, system-managed contexts do not require any specific privilege. To access custom (user-defined) contexts, you must have either SELECT ANY END USER CONTEXT system privilege, or, have the SELECT privilege granted through a data grant on SYS.END_USER_CONTEXT view for the specific context.

Syntax

Description of the illustration ora_end_user_context.gif

Semantics

Note that ORA_END_USER_CONTEXT does not take any arguments. It returns a complete list of pre-defined system attributes along with all instantiated contexts and their associated attributes.

The dot-annotation is supported because this function returns data in JSON type.

If HR.HCM context has been created and instantiated in the session, SELECT ORA_END_USER_CONTEXT from dual; returns the following:

{
  "USERNAME" : "SCOTT",
  "LOGON_END_USER": "SCOTT",
  "CURRENT_END_USER": "SCOTT",
  "USER" : {
      "TOKEN" : {
          "TOKEN_ID" : xxx
          ...
      }
   },
  "HR" : {
    "HCM" : {
      "emp_id": 3
      "service_center_id": 5
     }
  }
}

Note that the top-level attributes as shown in above example, USERNAME, LOGON_END_USER, CURRENT_END_USER, and the context USER.TOKEN, are the pre-defined system attributes. They are by default available to all end users.

There are two pre-defined, system-managed contexts available in every end-user security context and do not requre explicit instantiation. You cannot modify attributes in these contexts directly, they are initialized by the database server based on the user identity propagated from IAM.

You can reference the attributes of context USER.DEFAULT directly using ORA_END_USER_CONTEXT .

The syntax follows the standard JSON dot path notation, so, SELECT ORA_END_USER_CONTEXT.HR.HCM FROM dual returns:

{
  "emp_id": 3,
  "service_center_id": 5
}

SELECT ORA_END_USER_CONTEXT.HR FROM dual returns:

{
      "HCM" :    {
      "emp_id": 3
      "service_center_id": 5
   }
}

To reference a particular attribute, owner, name, and attribute all need to exist. For example, SELECT ORA_END_USER_CONTEX.HR.HCM.emp_id FROM dual returns 3.