Oracle8i SQL Reference
Release 3 (8.1.7)

Part Number A85397-01

Library

Product

Contents

Index

Go to previous page Go to beginning of chapter Go to next page

SQL Statements:
CREATE CLUSTER to CREATE SEQUENCE, 3 of 25


CREATE CONTEXT

Purpose

Use the CREATE CONTEXT statement to create a namespace for a context (a set of application-defined attributes that validates and secures an application) and to associate the namespace with the externally created package that sets the context. You can use the DBMS_SESSION.set_context procedure in your designated package to set or reset the attributes of the context.

See Also:

 

Prerequisites

To create a context namespace, you must have CREATE ANY CONTEXT system privilege.

Syntax


Keywords and Parameters

OR REPLACE

Specify OR REPLACE to redefine an existing context namespace using a different package.

namespace

Specify the name of the context namespace to create or modify. Context namespaces are always stored in the schema SYS.

schema

Specify the schema owning package. If you omit schema, Oracle uses the current schema.

package

Specify the PL/SQL package that sets or resets the context attributes under the namespace for a user session.


Note: To provide some design flexibility, Oracle does not verify the existence of the schema or the validity of the package at the time you create the context. 


See Also: Oracle8i Supplied PL/SQL Packages Reference for more information on setting the package 

Examples

CREATE CONTEXT Example

Suppose you have a human resources (hr) application and a PL/SQL package (hr_secure_context), which validates and secures the hr application. The following statement creates the context namespace hr_context and associates it with the package hr_secure_context:

CREATE CONTEXT hr_context USING hr_secure_context;

You can control data access based on this context using the SYS_CONTEXT function. For example, suppose your hr_secure_context package has defined an attribute org_id as a particular organization identifier. You can secure a base table hr_org_unit by creating a view that restricts access based on the value of org_id, as follows:

CREATE VIEW hr_org_secure_view AS
     SELECT * FROM hr_org_unit
     WHERE organization_id = SYS_CONTEXT('hr_context', 'org_id');

See Also: SYS_CONTEXT for more information on the SYS_CONTEXT function 


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 1996-2000, Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index