Oracle Database

Page 249

Using Global Application Contexts

At this stage, the client session ID, 34256 is still in place, but the application context settings no longer exist. This enables you to continue the session for this user but without using the previously set application context values.

Step 5: Remove the Components for This Example 1.

Log on as SYS and connect using AS SYSDBA. CONNECT SYS/AS SYSDBA Enter password: password

2.

Drop the global application context. DROP CONTEXT global_cust_ctx;

Remember that even though sysadmin_ctx created the global application context, it is owned by the SYS schema. 3.

Drop the two sample users. DROP USER sysadmin_ctx CASCADE; DROP USER apps_user;

Global Application Context Processes This section provides two examples of how a global application context can be processed. â–

Simple Global Application Context Process

â–

Global Application Context Process for Lightweight Users

Simple Global Application Context Process Consider the application server, AppSvr, that has assigned the client identifier 12345 to client scott. The AppSvr application uses the scott user to create a session (that is, it is not a connection pool.) The value assigned to the context attribute can come from anywhere, for example, from running a SELECT statement on a table that holds the responsibility codes for users. When the application context is populated, it is stored in memory. As a result, any action that needs the responsibility code can access it quickly with SYS_CONTEXT call, without the overhead of accessing a table. The only advantage of a global context over a local context in this case is if scott were changing applications frequently and used the same context in each application. The following steps show how the global application context process sets the client identifier for scott. 1.

The administrator creates a global context namespace by using the following statement: CREATE OR REPLACE CONTEXT hr USING hr.init ACCESSED GLOBALLY;

2.

The administrator creates a PL/SQL package for the HR application context to indicate that, for this client identifier, there is an application context called responsibility with a value of 13 in the HR namespace.: CREATE OR REPLACE PROCEDURE hr.init AS BEGIN DBMS_SESSION.SET_CONTEXT( namespace => 'HR',

Using Application Contexts to Retrieve User Information 7-35


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.