Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
40
Добавлен:
16.04.2013
Размер:
4.96 Mб
Скачать

Examples of Trigger Applications

The library_view is an updatable view, and any INSERTs on the view are handled by the trigger that gets fired automatically. For example:

INSERT INTO Library_view VALUES ('History', book_list_t(book_t(121330, 'Alexander', 'Mirth', 'Y');

Similarly, you can also define triggers on the nested table booklist to handle modification of the nested table element.

Tracking System Events Using Triggers

Fine-Grained Access Control Using Triggers: Example System triggers can be used to set application context. Application context is a relatively new feature that enhances your ability to implement fine-grained access control. Application context is a secure session cache, and it can be used to store session-specific attributes.

In the example that follows, procedure set_ctx sets the application context based on the user profile. The trigger setexpensectx ensures that the context is set for every user.

CONNECT secdemo/secdemo

CREATE OR REPLACE CONTEXT Expenses_reporting USING Secdemo.Exprep_ctx;

REM =================================================================

REM Creation of the package which implements the context:

REM =================================================================

CREATE OR REPLACE PACKAGE Exprep_ctx AS

PROCEDURE Set_ctx;

END;

SHOW ERRORS

CREATE OR REPLACE PACKAGE BODY Exprep_ctx IS

PROCEDURE

Set_ctx IS

Empnum

NUMBER;

Countrec NUMBER;

Cc

NUMBER;

Role

VARCHAR2(20);

BEGIN

 

-- SET

emp_number:

SELECT

Employee_id INTO Empnum FROM Employee

Using Triggers 9-49

Соседние файлы в папке Oracle 10g