SYS_CONTEXT

The SYS_CONTEXT function returns the value of parameter associated with the context namespace.

See also:

For more information, see the SYS_CONTEXT function in Oracle Database SQL Language Reference.

Return Values

VARCHAR2.

Syntax

SYS_CONTEXT(namespace, parameter [, length ])

Parameters

namespace

A text expression that specifies a namespace which is a valid SQL identifier. The context namespace must have been created, and the associated parameter and its value must also have been set using the DBMS_SESSION.set_context procedure.

parameter

A text expression that specifies an attribute associated with a namespace. This parameter and its value must have previously been set using the DBMS_SESSION.set_context procedure. The parameter is not case sensitive, but it cannot exceed 30 bytes in length.

length

A numeric expression that specifies the maximum size of the return value. The value that you specify must be a NUMBER (or a value that can be implicitly converted to NUMBER) and in the range of 1 to 4000 bytes,. If you specify an invalid value, then Oracle OLAP ignores it and uses the default value of 256 bytes.

Usage Notes

USERENV Built-In Namespace

Oracle provides a built-in namespace called USERENV, which describes the current session.

For more information on the predefined parameters of namespace USERENV, see the SYS_CONTEXT function in Oracle Database SQL Language Reference.

Examples

Example 8-125 Retrieving the Name of the User of the Session

The following hypothetical example retrieves the value JOHNSMITH which is the name of the user who logged onto the database.

SHOW SYS_CONTEXT ('USERENV', 'SESSION_USER')
JOHNSMITH