XS_SYS_CONTEXT Function
The XS_SYS_CONTEXT function provides quick access to session attributes in the current application session without incurring the overhead that results from using the PL/SQL APIs. The SYS_XS_CONTEXT function definition mirrors that of the SYS_CONTEXT function and can be described as application session counterpart to SYS_CONTEXT. XS_SYS_CONTEXT and returns the requested namespace and attribute. If they do not exist, then it returns NULL.
Predefined Parameters lists the attributes in predefined namespace XS$SESSION.
Predefined Parameters
| Parameter | Return Value |
|---|---|
| CREATED_BY | The owner who created the current application session. |
| CREATE_TIME | The time in which the current application session was created. |
| COOKIE | The secure session cookie, passed as the parameter, that can be used to identify the newly created Real Application Security application session in future calls, until the cookie value is changed or the session is destroyed. |
| CURRENT_XS_USER | The name of the Real Application Security session application user whose privileges are currently active. |
| CURRENT_XS_USER_GUID | The identifier of the Real Application Security session application user whose privileges are currently active. |
| INACTIVITY_TIMEOUT | The specified inactivity timeout value in minutes for the current application session. |
| LAST_ACCESS_TIME | The last time the session was accessed by a session application user. |
| LAST_AUTHENTICATION_TIME | The last time the session application user was authenticated. |
| LAST_UPDATED_BY | The last time the application session was updated. |
| PROXY_GUID | Identifier of the Real Application Security session application user who opened the current session on behalf of SESSION_XS_USER. |
| SESSION_ID | The session identifier for the application session. |
| SESSION_XS_USER | The name of the Real Application Security session application user at logon. |
| SESSION_XS_USER_GUID | The identifier of the Real Application Security session application user at logon. |
| USERNAME | The session application user name. |
| USER_ID | The identifier of the session application user. |
To retrieve the name of the currently attached Real Application Security session application user, you can use the following form of the XS_SYS_CONTEXT function:
XS_SYS_CONTEXT('XS$SESSION', 'SESSION_XS_USER')
The function returns NULL if no Real Application Security session is currently attached to the database session. The function returns the currently attached Real Application Security session application user even if it is called from within the body of a definer’s rights unit, like a definer’s rights view.
To retrieve the identifier (ID) for the currently attached Real Application Security session application user, you can use the following form of the XS_SYS_CONTEXT function:
XS_SYS_CONTEXT('XS$SESSION', 'SESSION_XS_USER_GUID')
The function returns NULL if no Real Application Security session is currently attached to the database session. The function returns the currently attached Real Application Security session application user ID even if it is called from within the body of a definer’s rights unit, like a definer’s rights view.
Syntax
XS_SYS_CONTEXT(
namespace IN VARCHAR2
attribute IN VARCHAR2)
RETURN VARCHAR2;
Parameters
| Parameter | Description |
|---|---|
namespace |
The name of the application context. You can specify either a string or an expression. To find information about the namespaces and attributes for the current application session, query the V$XS_SESSION_NS_ATTRIBUTES data dictionary view. |
attribute |
A parameter within the namespace application context. |
Example
SELECT XS_SYS_CONTEXT('XS$SESSION', 'SESSION_ID') FROM DUAL;