In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
What this article shares with you is about how to use the sys_context function correctly. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
The sys_context function is a predefined function provided by Oracle to obtain context information of the environment. This function returns a parameter value under the specified namespace. This function can be used in sql and PL/SQL languages. Sys_context is actually a container access function for Oracle to store and pass parameters. We log in to the Oracle server with session information and other attribute information. Some of them are predefined by Oracle and are automatically filled in to the specified variables when logging in to the system. The other function, userenv (), remains compatible with it.
Here is some information that can be obtained through the sys_context function:
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
Sys_context ('USERENV',' ISDBA') isdba
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_date_language
Sys_context ('USERENV',' NLS_SORT') nls_sort
Sys_context ('USERENV',' CURRENT_USER') current_user
Sys_context ('USERENV',' CURRENT_USERID') current_userid
Sys_context ('USERENV',' SESSION_USER') session_user
Sys_context ('USERENV',' SESSION_USERID') session_userid
Sys_context ('USERENV',' PROXY_USER') proxy_user
Sys_context ('USERENV',' PROXY_USERID') proxy_userid
Sys_context ('USERENV',' DB_DOMAIN') db_domain
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
Sys_context ('USERENV',' MODULE') module
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',' AUTHENTICATION_DATA') authentication_data
Sys_context ('userenv',' SID') from dual
From dual
We can also define context parameters to pass values. Here is the format of the sys_context function:
Sys_context ('namespace',' parameter' {, length})
Where namespace is a group unit for storing information, and namespace is classified by category. There can be multiple parameter values under a namespace, which can be distinguished by different parameter. Namespace is a predefined SQL identifier, while parameter is an arbitrary case-insensitive string with a length of no more than 30 bits. The return value of the function is of type varchar2, and the length defaults to 256 bits. If you need to limit this default value, you can use the length parameter as the new return length value.
Set namespace to specify the parameter value, which can be done using the dbms_session.set_context method:
-- 1. Define namespace
Create context Test using set_test_context
-- 2. Definition method
Create or replace procedure set_test_context (vc_value in varchar2) is
Begin
Dbms_session.set_context ('Test', 'a1century, vc_value)
End
-- 3. Set value
Exec set_test_context ('m')
-- 4. Get the value
Select sys_context ('Test', 'a1') from dual
SYS_CONTEXT ('TEST','A1')
-
M
The above is how to correctly use the sys_context function, the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.