This Oracle tutorial explains how to use the Oracle/PLSQL USERENV function with syntax and examples.
The Oracle/PLSQL USERENV function can be used to retrieve information about the current Oracle session. Although this function still exists in Oracle for backwards compatibility, it is recommended that you use the SYS_CONTEXT function instead.
The syntax for the USERENV function in Oracle/PLSQL is:
The value to return from the current Oracle session. The possible values are:
Parameter | Explanation |
---|---|
CLIENT_INFO | Returns user session information stored using the DBMS_APPLICATION_INFO package |
ENTRYID | Available auditing entry identifier |
INSTANCE | The identifier number of the current instance |
ISDBA | Returns TRUE if the user has DBA privileges. Otherwise, it will return FALSE. |
LANG | The ISO abbreviation for the language |
LANGUAGE | The language, territory, and character of the session in the following format: language_territory.characterset |
SESSIONID | The identifier of the auditing session |
SID | The session ID |
TERMINAL | The OS identifier of the current session |
The USERENV function returns a numeric value when the following parameters are provided: ENTRYID, SESSIONID, SID. The USERENV function returns a VARCHAR2 when the following parameters are provided: CLIENT_INFO, INSTANCE, ISDBA, LANG, LANGUAGE, TERMINAL.
The USERENV function can be used in the following versions of Oracle/PLSQL:
Let's look at some Oracle USERENV function examples and explore how to use the USERENV function in Oracle/PLSQL.
For example: