Oracle8i SQL Reference
Release 2 (8.1.6)

A76989-01

Library

Product

Contents

Index

Prev Up Next

SQL Statements (continued), 2 of 20


CREATE CONTEXT

Syntax


Purpose

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.

See Also:

Oracle8i Concepts for a definition and discussion of contexts. 

Prerequisites

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

Keywords and Parameters

OR REPLACE 

redefines an existing context namespace using a different package. 

namespace 

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

schema 

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

package 

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

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

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. 

Examples

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. 


Prev Up Next
Oracle
Copyright © 1999 Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index