Databases Reference
In-Depth Information
VPD and Application Context
VPD can be used in combination with Application Context, a very common
combination of techniques. In this section, Application Context is explained and an
example is shown that explains how Application Context can play a role in VPD.
An Application Context is a namespace, which you can deine yourself and where
you can store name-value pairs. It may sound complicated, but it is not. It will all
be explained in the following example.
To work with an Application Context, the irst thing that is needed is the Application
Context itself. The Application Context is created by issuing the following command:
In order to be able to create a context, the CREATE
ANY CONTEXT privilege must be granted to the user.
In the preceding code, an Application Context is created with the namespace called
docman_ctx . Since it is not allowed to manipulate the name-value pairs directly, a
package or procedure is needed to do so. Note that the package mentioned in the
code ( dm_context_pkg ) has not been created yet. Of course, you can irst create the
package with all of the required procedures, but this is not strictly necessary.
Now that the Application Context is created, the package needs to be created in
order to place the name-value pairs in the Application Context. Name-value pairs are
placed inside the Application Context using the DBMS_SESSION built-in package. In
this built-in package, there is a procedure appropriately called SET_CONTEXT , which
takes three mandatory parameters, NAMESPACE , ATTRIBUTE , and VALUE . There are
two more arguments that the procedure can take, but these are beyond the scope of
this chapter to cover.
Manipulating the Application Context directly using the DBMS_SESSION built-in
package is not allowed. This needs to be done by the package (or procedure) that
is mentioned when the Application Context is created. This package will act as a
wrapper around the DBMS_SESSION package.
 
Search WWH ::




Custom Search