In ORACLE, the context sys_context is used for the creation of sys_context and the system on which the application is recently used. Therefore, I searched the internet and wrote it down for emergency purposes. First, what is context? I think it is a public variable. The following is an explanation of "inthirties (thirty seconds)": DBMS_SESSION.SET_CONTEXT (namespace VARCHAR2, attribute VARCHAR2, value VARCHAR2, username VARCHAR2, client_id VARCHAR2 ); the meanings of several parameters here are the attributes of the namespace context namespace, that is, the value of the key value username default null client_id specified clientid default null here 1-3 functions are required, the following two values are optional. The sys_context user is similar to the userenv user and maintains the session-level context related to the session. This context is accessible to all sessions, so if we need to put some session-level information here, we can use this sys_context context. Since it is a public variable, you can define it yourself!
1SQL> DBMS_SESSION.set_context('testcontext', 'con2','abcd');2 3DBMS_SESSION.set_context('testcontext', 'con2','abcd')4 5ORA-00900: invalid SQL statement
An error is reported! Generate through the process:
1 create or replace procedure execcontext (contextkey in varchar2, contextvalue in varchar2) 2 3AS4 BEGIN5DBMS_SESSION.set_context ('testcontext', contextkey, contextvalue); 6END; same error! 1SQL> exec execconttext ('aaa', 'bbb'); 2 3 begin execconttext ('aaa', 'bbb'); end; 4 5ORA-06550: line 2, column 7: 6PLS-00201: identifier 'execconttext' must be declared7ORA-06550: line 2, column 7: 8PL/SQL: Statement ignored
To use a process to define the context, you must declare
01SQL> create or replace context testcontext using execcontext; 02 03 Context created04 05SQL> exec execcontext ('A', 'bb '); 06 07PL/SQL procedure successfully completed08 09SQL> select sys_context ('testcontext', 'A') from dual; 10 11SYS_CONTEXT ('testcontext ', 'A' 12 listen 13bb14 15SQL> in addition to the Internet through the packet definition context, usually reported: 1ORA-01031: insufficient privileges2ORA-06512: at "SYS. DBMS_SESSION ", line 1013ORA-06512: at" SCOTT. PROCNAME ", line 54ORA-06512: at line 2 This is a permission issue: Add ACCESSED GLOBALLY1SQL> create or replace context mycontext using MY_PACK_CONTEXT accessed globally when you need to declare it;
The process is as follows:
01--1. process of compiling definition context 02 create or replace procedure execcontext (contextkey in varchar2, contextvalue in varchar2) 03 04AS05 BEGIN06DBMS_SESSION.set_context ('testcontext', contextkey, contextvalue) 07END; 0809--2. The Declaration context can be used to define 10 create or replace context testcontext using execcontext; 1112--3. Below we can define 13SQL> exec execcontext ('A', 'bb '); 14 15PL/SQL procedure successfully completed1617 -- 4. For applications, see what 18SQL> select sys_context ('testcontext', 'A') from dual; 19 20SYS_CONTEXT ('testcontext ', 'A' 21 ------------------------------------------------------------------------------------ 22bb