Databases Reference
In-Depth Information
This section addresses the support for active rules in Oracle8, describes
how the Oracle8 rule system can be applied to the example application from
Section 3.2, and addresses the relationship between the Oracle rule language
and the emerging SQL: 1999 industry standard.
3.5.1 Active Rules in Oracle
This section describes the Oracle active rule language, illustrating its features
using examples based on the application from Section 3.2.
The following is a simple example of an Oracle active rule, which, every
time someone from a computing company registers, stores in the enrollment
table a tuple to indicate that the new attendee takes the course CS0. This is
an example of a causal business policy.
create or replace trigger addCS0
after insert on attendee
for each row
when (new.company = 'Computing')
begin
insert into enrollment values
(:new.a#, 'CS0', NULL);
end;
This command uses a significant range of features of the Oracle rule language:
1.
Active rules are known as triggers in Oracle, and every trigger has a
name (in this case, addCS0 ).
2.
The event is declared using the same syntax as in Section 3.4.1.
Events can monitor insert, delete,orupdate operations on tables.
Stored
procedure
invocations
cannot
be
monitored
by
event
definitions.
3.
The for each row clause indicates that this is a trigger with tuple-level
transition granularity that has an immediate coupling mode.
4.
The condition is declared in the when clause. The condition is a
boolean expression—it is not possible to embed complete SQL
queries in the when clause. The condition can refer to values associ-
ated with the event using old and/or new. If an action contains
functionality, the execution of which needs to be conditional on
information stored in the DB, the conditionality needs to be cap-
tured in the action itself.
Search WWH ::




Custom Search