Oracle Database

Page 224

Using Database Session-Based Application Contexts

Line 2: Takes emp_value as the input parameter. This parameter specifies the value associated with the application context attribue empno_attrib. Its limit is 4000 bytes. Line 5: Sets the value of the application context by using the DBMS_ SESSION.SET_CONTEXT procedure: –

'empno_ctx': Refers to the application context namespace. Enclose its name in single quotation marks.

'empno_attrib': Creates the attribute associated with the application context namespace.

ctx_value: Specifies the value for the empno_attrib attribute. Here, it refers to the ctx_value parameter defined in Line 2.

At this stage, you can run the set_empno_ctx_proc procedure to set the application context: EXECUTE set_empno_ctx_proc ('42783');

(In a real world scenario, you would set the application context values in the procedure itself, so that it becomes a trusted procedure. This example is only used to show how data can be set for demonstration purposes.) To check the application context setting, run the following SELECT statement: SELECT SYS_CONTEXT ('empno_ctx', 'empno_attrib') empno_attrib FROM DUAL; EMPNO_ATTRIB -------------42783

You can also query the SESSION_CONTEXT data dictionary view to find all the application context settings in the current session of the database instance. For example: SELECT * FROM SESSION_CONTEXT; NAMESPACE ATTRIBUTE VALUE -------------------------------------------------EMPNO_CTX EMP_ID 42783

See Also: ■

"Example of Creating and Using a Database Session-Based Application Context" on page 7-11 for how to create package that retrieves the user session information and then sets the application context based on this information Oracle Database PL/SQL Packages and Types Reference for detailed information about the DBMS_SESSION.SET_CONTEXT procedure

Creating a Logon Trigger to Run a Database Session Application Context Package After you create the application context and its associated package, the user needs to run the package when he or she logs on. You can create a logon trigger that handles this automatically. You do not need to grant the user EXECUTE permissions to run the package.

7-10

Oracle Database Security Guide


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