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

 

 

 

List of Database Events

 

 

 

 

 

Table 10–1 (Cont.) System-Defined Event Attributes

 

 

 

 

 

 

 

Attribute

Type

Description

Example

 

 

 

 

 

 

ora_sysevent

VARCHAR2(20)

System event

INSERT INTO event_table (ora_

 

 

 

firing the trigger:

sysevent);

 

 

 

Event name is

 

 

 

 

same as that in

 

 

 

 

the syntax.

 

 

 

 

 

 

 

ora_with_grant_option

BOOLEAN

Returns true if

if (ora_sysevent = 'GRANT' and

 

 

 

the privileges are

ora_with_grant_option = TRUE)

 

 

 

granted with

then insert into event_table

 

 

 

grant option.

('with grant option');

 

 

 

 

 

 

 

 

end if;

 

 

 

 

 

 

space_error_info(

BOOLEAN

Returns true if

if (space_error_info(eno, typ,

 

error_number OUT NUMBER,

 

the error is

owner, ts, obj, subobj) = TRUE)

 

error_type OUT VARCHAR2,

 

related to an

then

 

object_owner OUT VARCHAR2,

 

out-of-space

dbms_output.put_line('The

 

 

condition, and

 

table_space_name OUT

 

object ' || obj || ' owned by '

 

 

fills in the OUT

 

VARCHAR2,

 

|| owner || ' has run out of

 

 

parameters with

 

object_name OUT VARCHAR2,

 

information

space.');

 

sub_object_name OUT

 

end if;

 

 

about the object

 

VARCHAR2)

 

that caused the

 

 

 

 

error.

 

 

 

 

 

 

 

List of Database Events

System Events

System events are related to entire instances or schemas, not individual tables or rows. Triggers created on startup and shutdown events must be associated with the database instance. Triggers created on error and suspend events can be associated with either the database instance or a particular schema.

Table 10–2 contains a list of system manager events.

Working With System Events 10-7

List of Database Events

Table 10–2 System Manager Events

 

 

 

Attribute

Event

When Fired?

Conditions Restrictions Transaction

Functions

STARTUP

When the database is

None

No database

Starts a

 

opened.

allowed

operations

separate

 

 

 

allowed in the

transaction and

 

 

 

trigger.

commits it after

 

 

 

Return status

firing the

 

 

 

triggers.

 

 

 

ignored.

 

 

 

 

ora_sysevent ora_login_user ora_instance_num ora_database_name

SHUTDOWN

Just before the server starts

None

No database

Starts a

 

the shutdown of an

allowed

operations

separate

 

instance.

 

allowed in the

transaction and

 

This lets the cartridge

 

trigger.

commits it after

 

 

 

firing the

 

shutdown completely. For

 

Return status

 

 

triggers.

 

abnormal instance

 

ignored.

 

 

 

 

shutdown, this event may

 

 

 

 

not be fired.

 

 

 

ora_sysevent ora_login_user ora_instance_num ora_database_name

SERVERERROR When the error eno

ERRNO =

Depends on

Starts a

occurs. If no condition is

eno

the error.

separate

given, then this event fires

 

Return status

transaction and

when any error occurs.

 

commits it after

 

ignored.

Does not apply to

 

firing the

 

 

 

 

triggers.

ORA-1034, ORA-1403,

 

 

 

 

 

ORA-1422, ORA-1423, and

 

 

 

ORA-4030 conditions,

 

 

 

because they are not true

 

 

 

errors or are too serious to

 

 

 

continue processing.

 

 

 

ora_sysevent ora_login_user ora_instance_num ora_database_name ora_server_error ora_is_ servererror space_error_info

Client Events

Client events are the events related to user logon/logoff, DML, and DDL operations. For example:

CREATE OR REPLACE TRIGGER On_Logon

AFTER LOGON

ON The_user.Schema

BEGIN

Do_Something;

END;

10-8 Oracle Database Application Developer's Guide - Fundamentals

List of Database Events

The LOGON and LOGOFF events allow simple conditions on UID( ) and USER( ). All other events allow simple conditions on the type and name of the object, as well as functions like UID( ) and USER( ).

The LOGON event starts a separate transaction and commits it after firing the triggers. All other events fire the triggers in the existing user transaction.

The LOGON and LOGOFF events can operate on any objects. For all other events, the corresponding trigger cannot perform any DDL operations, such as DROP and ALTER, on the object that caused the event to be generated.

The DDL allowed inside these triggers is altering, creating, or dropping a table, creating a trigger, and compile operations.

If an event trigger becomes the target of a DDL operation (such as CREATE TRIGGER), it cannot be fired later during the same transaction

Table 10–3 contains a list of client events.

Working With System Events 10-9

List of Database Events

Table 10–3

Client Events

 

 

 

 

 

 

Event

 

When Fired?

Attribute Functions

 

 

 

 

BEFORE ALTER

 

When a catalog object is altered.

ora_sysevent

 

 

 

ora_login_user

AFTER ALTER

 

 

ora_instance_num

 

 

 

ora_database_name

 

 

 

ora_dict_obj_type

 

 

 

ora_dict_obj_name

 

 

 

ora_dict_obj_owner

 

 

 

ora_des_encrypted_password

 

 

 

(for ALTER USER events)

 

 

 

ora_is_alter_column, ora_is_

 

 

 

drop_column (for ALTER TABLE

 

 

 

events)

 

 

 

 

BEFORE DROP

 

When a catalog object is dropped.

ora_sysevent

 

 

 

ora_login_user

AFTER DROP

 

 

ora_instance_num

 

 

 

ora_database_name

 

 

 

ora_dict_obj_type

 

 

 

ora_dict_obj_name

 

 

 

ora_dict_obj_owner

 

 

 

BEFORE ANALYZE

When an analyze statement is

ora_sysevent

 

 

issued

ora_login_user

AFTER ANALYZE

 

ora_instance_num

 

 

 

ora_database_name

 

 

 

ora_dict_obj_name

 

 

 

ora_dict_obj_type

 

 

 

ora_dict_obj_owner

 

 

 

BEFORE ASSOCIATE STATISTICS

When an associate statistics

ora_sysevent

 

 

statement is issued

ora_login_user

AFTER ASSOCIATE STATISTICS

 

ora_instance_num

 

 

 

ora_database_name

 

 

 

ora_dict_obj_name

 

 

 

ora_dict_obj_type

 

 

 

ora_dict_obj_owner

 

 

 

ora_dict_obj_name_list

 

 

 

ora_dict_obj_owner_list

 

 

 

 

BEFORE AUDIT

 

When an audit or noaudit

ora_sysevent

AFTER AUDIT

 

statement is issued

ora_login_user

 

 

 

ora_instance_num

BEFORE NOAUDIT

 

ora_database_name

AFTER NOAUDIT

 

 

 

 

 

 

10-10 Oracle Database Application Developer's Guide - Fundamentals

 

 

 

List of Database Events

 

 

 

 

 

Table 10–3 (Cont.)

Client Events (Cont.)

 

 

 

 

 

 

 

Event

 

When Fired?

Attribute Functions

 

 

 

 

 

 

BEFORE COMMENT

 

When an object is commented

ora_sysevent

 

 

 

 

ora_login_user

 

AFTER COMMENT

 

 

ora_instance_num

 

 

 

 

ora_database_name

 

 

 

 

ora_dict_obj_name

 

 

 

 

ora_dict_obj_type

 

 

 

 

ora_dict_obj_owner

 

 

 

 

 

 

BEFORE CREATE

 

When a catalog object is created.

ora_sysevent

 

 

 

 

ora_login_user

 

AFTER CREATE

 

 

ora_instance_num

 

 

 

 

ora_database_name

 

 

 

 

ora_dict_obj_type

 

 

 

 

ora_dict_obj_name

 

 

 

 

ora_dict_obj_owner

 

 

 

 

ora_is_creating_nested_table

 

 

 

 

(for CREATE TABLE events)

 

 

 

 

 

 

BEFORE DDL

 

When most SQL DDL statements

ora_sysevent

 

 

 

are issued. Not fired for ALTER

ora_login_user

 

AFTER DDL

 

DATABASE, CREATE

ora_instance_num

 

 

 

CONTROLFILE, CREATE

ora_database_name

 

 

 

DATABASE, and DDL issued

 

 

 

ora_dict_obj_name

 

 

 

through the PL/SQL procedure

 

 

 

ora_dict_obj_type

 

 

 

interface, such as creating an

 

 

 

ora_dict_obj_owner

 

 

 

advanced queue.

 

 

 

 

 

 

 

 

 

 

BEFORE DISASSOCIATE

 

When a disassociate statistics

ora_sysevent

 

STATISTICS

 

statement is issued

ora_login_user

 

 

 

 

ora_instance_num

 

AFTER DISASSOCIATE STATISTICS

 

ora_database_name

 

 

 

 

ora_dict_obj_name

 

 

 

 

ora_dict_obj_type

 

 

 

 

ora_dict_obj_owner

 

 

 

 

ora_dict_obj_name_list

 

 

 

 

ora_dict_obj_owner_list

 

 

 

 

 

 

Working With System Events 10-11

List of Database Events

Table 10–3 (Cont.)

Client Events (Cont.)

 

 

 

 

 

Event

 

When Fired?

Attribute Functions

 

 

 

 

BEFORE GRANT

 

When a grant statement is issued

ora_sysevent

 

 

 

ora_login_user

AFTER GRANT

 

 

ora_instance_num

 

 

 

ora_database_name

 

 

 

ora_dict_obj_name

 

 

 

ora_dict_obj_type

 

 

 

ora_dict_obj_owner

 

 

 

ora_grantee

 

 

 

ora_with_grant_option

 

 

 

ora_privileges

 

 

 

 

BEFORE LOGOFF

 

At the start of a user logoff

ora_sysevent

 

 

 

ora_login_user

 

 

 

ora_instance_num

 

 

 

ora_database_name

 

 

 

 

AFTER LOGON

 

After a successful logon of a user.

ora_sysevent

 

 

 

ora_login_user

 

 

 

ora_instance_num

 

 

 

ora_database_name

 

 

 

ora_client_ip_address

 

 

 

 

BEFORE RENAME

 

When a rename statement is

ora_sysevent

 

 

issued.

ora_login_user

AFTER RENAME

 

 

ora_instance_num

 

 

 

ora_database_name

 

 

 

ora_dict_obj_name

 

 

 

ora_dict_obj_owner

 

 

 

ora_dict_obj_type

 

 

 

 

10-12 Oracle Database Application Developer's Guide - Fundamentals

 

 

 

List of Database Events

 

 

 

 

 

Table 10–3 (Cont.)

Client Events (Cont.)

 

 

 

 

 

 

 

Event

 

When Fired?

Attribute Functions

 

 

 

 

 

 

BEFORE REVOKE

 

When a revoke statement is issued

ora_sysevent

 

 

 

 

ora_login_user

 

AFTER REVOKE

 

 

ora_instance_num

 

 

 

 

ora_database_name

 

 

 

 

ora_dict_obj_name

 

 

 

 

ora_dict_obj_type

 

 

 

 

ora_dict_obj_owner

 

 

 

 

ora_revokee

 

 

 

 

ora_privileges

 

 

 

 

 

 

AFTER SUSPEND

 

After a SQL statement is

ora_sysevent

 

 

 

suspended because of an

ora_login_user

 

 

 

out-of-space condition. The trigger

ora_instance_num

 

 

 

should correct the condition so the

ora_database_name

 

 

 

statement can be resumed.

ora_server_error

 

 

 

 

 

 

 

 

ora_is_servererror

 

 

 

 

space_error_info

 

 

 

 

 

 

BEFORE TRUNCATE

 

When an object is truncated

ora_sysevent

 

 

 

 

ora_login_user

 

AFTER TRUNCATE

 

 

ora_instance_num

 

 

 

 

ora_database_name

 

 

 

 

ora_dict_obj_name

 

 

 

 

ora_dict_obj_type

 

 

 

 

ora_dict_obj_owner

 

 

 

 

 

 

Working With System Events 10-13

List of Database Events

10-14 Oracle Database Application Developer's Guide - Fundamentals

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