8.3 SET_CONTEXT: Setting Context and Attribute ValuesThe 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 .
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
Copyright (c) 2000 O'Reilly & Associates. All rights reserved. |
|