Oracle Plsql Userenv Function

Oracle / PLSQL: USERENV Function

This Oracle tutorial explains how to use the Oracle/PLSQL USERENV function with syntax and examples.

Description

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.

Syntax

The syntax for the USERENV function in Oracle/PLSQL is:

USERENV( parameter )

Parameters or Arguments

parameter

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

Returns

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.

Applies To

The USERENV function can be used in the following versions of Oracle/PLSQL:

  • Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i

Example

Let's look at some Oracle USERENV function examples and explore how to use the USERENV function in Oracle/PLSQL.

For example:

USERENV('ENTRYID')
Output: 0

USERENV('LANGUAGE')
Output: 'AMERICAN_AMERICA.WE8DEC'