8.3 SET_CONTEXT: Setting Context and Attribute Values

Team-Fly    

 
Oracle PL/SQL Programming Guide to Oracle 8 i Features
By Steven Feuerstein
Table of Contents
Chapter 8.  Deploying Fine-Grained Access Control


The DBMS_SESSION built-in package has been enhanced with the SET_CONTEXT procedure so that you can set the value for an attribute within a context. Here is the header for that procedure:

 PROCEDURE DBMS_SESSION.SET_CONTEXT (    namespace VARCHAR2,     attribute VARCHAR2,     value VARCHAR2); 

The parameters are listed in Table 8.2.

Table 8.2. SET_CONTEXT Parameters

Parameter

Description

namespace

The name of the context

attribute

The attribute name

value

The value to be assigned to that attribute in the current session

This procedure can only be called inside the package specified for the namespace context in the CREATE CONTEXT statement. This relationship is shown in the following steps:

 /* Filename on companion disk: earth.pkg */     CREATE CONTEXT pollution_indicators USING earth_pkg; CREATE OR REPLACE PACKAGE earth_pkg IS    PROCEDURE set_contexts; END; / CREATE OR REPLACE PACKAGE BODY earth_pkg IS    c_context CONSTANT VARCHAR2(30) :=       'pollution_indicators';           PROCEDURE set_contexts IS     BEGIN          DBMS_SESSION.SET_CONTEXT (          c_context, 'acidrain', 'corrosive');       DBMS_SESSION.SET_CONTEXT (          c_context, 'smog', 'dense');    END; END; / 

If you try to execute DBMS_SESSION.SET_CONTEXT "out of context," you will get an error, as shown here:

 SQL> BEGIN      2     DBMS_SESSION.SET_CONTEXT (   3        'pollution_indicators', 'smog', 'dense');   4  END;   5  / BEGIN * ERROR at line 1: ORA-01031: insufficient privileges 

Team-Fly    
Top


Oracle PL. SQL Programming. Guide to Oracle8i Features
Oracle PL/SQL Programming: Guide to Oracle8i Features
ISBN: B000H2MK2W
EAN: N/A
Year: 1998
Pages: 107

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net