1) sys_context for PL/SQL and SQL
1@@@@This sql script could be run in sql*plus
[root@station78 sql]# cat sys_context.sql
set lines 200
col terminal format a20
col language format a40
col sessionid format a20
col instance format a20
col entryid format a20
SELECT
  sys_context('userenv','terminal') terminal,
  sys_context('userenv','language') language,
  sys_context('userenv','sessionid') sessionid,
  sys_context('userenv','instance') instance,
  sys_context('userenv','entryid') entryid
FROM dual
/


col nls_territory format a20
col nls_currency format a20
col nls_calendar format a20
col nls_date_format format a40
col nls_data_language format a20
SELECT
  sys_context('userenv','nls_territory') nls_territory,
  sys_context('userenv','nls_currency') nls_currency,
  sys_context('userenv','nls_calendar') nls_calendar,
  sys_context('userenv','nls_date_format') nls_date_format,
  sys_context('userenv','nls_date_language') nls_data_language
FROM dual
/

col nls_sort format a20
col current_user format a20
col current_userid format a20
col proxy_user format a20
col proxy_userid format a20
col db_domain format a20
SELECT
  sys_context('userenv','nls_sort') nls_sort,
  sys_context('userenv','current_user') current_user,
  sys_context('userenv','current_userid') current_userid,
  sys_context('userenv','proxy_user') proxy_user,
  sys_context('userenv','proxy_userid') proxy_userid,
  sys_context('userenv','db_domain') db_domain
FROM dual
/

col db_name format a20
col host format a40
col os_user format a20
col external_name format a20
col ip_address format a20

SELECT
  sys_context('userenv','db_name') db_name,
  sys_context('userenv','host') host,
  sys_context('userenv','os_user') os_user,
  sys_context('userenv','external_name') external_name,
  sys_context('userenv','ip_address') ip_address
FROM dual
/

col network_protocol format a20
col bg_job_id format a20
col fg_job_id format a20
col authentication_type format a20
col authentication_data format a20
col isdba format a20
SELECT
  sys_context('userenv','network_protocol') network_protocol,
  sys_context('userenv','bg_job_id') bg_job_id,
  sys_context('userenv','fg_job_id') fg_job_id,
  sys_context('userenv','authentication_type') authentication_type,
  sys_context('userenv','isdba') isdba,
  sys_context('userenv','authentication_data') authentication_data
FROM dual
/