SYS_CONTEXT

Oracle has a very useful built-in function called SYS_CONTEXT. The syntax of this function goes like this:

SYS_CONTEXT ( 'namespace' , 'parameter' [, length] )

SYS_CONTEXT returns the value of parameter associated with the context namespace. You can use this function in both SQL and PL/SQL statements.

What makes this function more interesting is the fact that Oracle provides a built-in namespace called USERENV with predefined parameters, which describes the current session. Go ahead and run the following query:

select 
sys_context('USERENV','AUTHENTICATION_TYPE')
,sys_context('USERENV','CURRENT_SCHEMA')
,sys_context('USERENV','CURRENT_SCHEMAID')
,sys_context('USERENV','CURRENT_USER')
,sys_context('USERENV','CURRENT_USERID')
,sys_context('USERENV','DB_DOMAIN')
,sys_context('USERENV','DB_NAME')
,sys_context('USERENV','HOST')
,sys_context('USERENV','INSTANCE')
,sys_context('USERENV','IP_ADDRESS')
,sys_context('USERENV','ISDBA')
,sys_context('USERENV','LANG')
,sys_context('USERENV','LANGUAGE')
,sys_context('USERENV','NETWORK_PROTOCOL')
,sys_context('USERENV','NLS_CALENDAR')
,sys_context('USERENV','NLS_CURRENCY')
,sys_context('USERENV','NLS_DATE_FORMAT')
,sys_context('USERENV','NLS_DATE_LANGUAGE')
,sys_context('USERENV','NLS_TERRITORY')
,sys_context('USERENV','OS_USER')
,sys_context('USERENV','SESSION_USER')
,sys_context('USERENV','SESSION_USERID')
,sys_context('USERENV','SESSIONID')
,sys_context('USERENV','TERMINAL')
from dual

Amazing , you can Use this Function in Oracle Security .

Enjoy

Thank you
Osama mustafa
 

One thought on “SYS_CONTEXT

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.