| PL/SQL Packages and Types Reference 10g Release 1 (10.1) Part Number B10802-01 |
|
|
View PDF |
The DBMS_RULE package contains subprograms that enable the evaluation of a rule set for a specified event.
See Also:
|
This chapter contains the following topics:
PUBLIC is granted execute privilege on this package.
This procedure closes an open iterator.
DBMS_RULE.CLOSE_ITERATOR( iterator IN NUMBER);
| Parameter | Description |
|---|---|
|
|
The iterator to be closed |
This procedure requires an open iterator that was returned by an earlier call to DBMS_RULE.EVALUATE in the same session. The user who runs this procedure does not require any privileges on the rule set being evaluated.
Closing an iterator frees resources, such as memory, associated with the iterator. Therefore, Oracle recommends that you close an iterator when it is no longer needed.
This procedure evaluates the rules in the specified rule set that use the evaluation context specified for a specified event.
This procedure is overloaded. The true_rules and maybe_rules parameters are mutually exclusive with the true_rules_iterator and maybe_rules_iterator parameters. In addition, the procedure with the true_rules and maybe_rules parameters includes the stop_on_first_hit parameter, but the other procedure does not.
DBMS_RULE.EVALUATE( rule_set_name IN VARCHAR2, evaluation_context IN VARCHAR2, event_context IN SYS.RE$NV_LIST DEFAULT NULL, table_values IN SYS.RE$TABLE_VALUE_LIST DEFAULT NULL, column_values IN SYS.RE$COLUMN_VALUE_LIST DEFAULT NULL, variable_values IN SYS.RE$VARIABLE_VALUE_LIST DEFAULT NULL, attribute_values IN SYS.RE$ATTRIBUTE_VALUE_LIST DEFAULT NULL, stop_on_first_hit IN BOOLEAN DEFAULT false, simple_rules_only IN BOOLEAN DEFAULT false, true_rules OUT SYS.RE$RULE_HIT_LIST, maybe_rules OUT SYS.RE$RULE_HIT_LIST); DBMS_RULE.EVALUATE( rule_set_name IN VARCHAR2, evaluation_context IN VARCHAR2, event_context IN SYS.RE$NV_LIST DEFAULT NULL, table_values IN SYS.RE$TABLE_VALUE_LIST DEFAULT NULL, column_values IN SYS.RE$COLUMN_VALUE_LIST DEFAULT NULL, variable_values IN SYS.RE$VARIABLE_VALUE_LIST DEFAULT NULL, attribute_values IN SYS.RE$ATTRIBUTE_VALUE_LIST DEFAULT NULL, simple_rules_only IN BOOLEAN DEFAULT false, true_rules_iterator OUT BINARY_INTEGER, maybe_rules_iterator OUT BINARY_INTEGER);
|
Note: Rules in the rule set that use an evaluation context different from the one specified are not considered for evaluation. |
The rules in the rule set are evaluated using the data specified for table_values, column_values, variable_values, and attribute_values. These values must refer to tables and variables in the specified evaluation context. Otherwise, an error is raised.
The caller may specify, using stop_on_first_hit, if evaluation must stop as soon as the first TRUE rule or the first MAYBE rule (if there are no TRUE rules) is found.
The caller may also specify, using simple_rules_only, if only rules that are simple enough to be evaluated fast (which means without SQL) should be considered for evaluation. This makes evaluation faster, but causes rules that cannot be evaluated without SQL to be returned as MAYBE rules.
Partial evaluation is supported. The EVALUATE procedure can be called with data for only some of the tables, columns, variables, or attributes. In such a case, rules that cannot be evaluated because of a lack of data are returned as MAYBE rules, unless they can be determined to be TRUE or FALSE based on the values of one or more simple expressions within the rule. For example, given a value of 1 for attribute "a.b" of variable "x", a rule with the following rule condition can be returned as TRUE, without a value for table "tab":
(:x.a.b = 1) or (tab.c > 10)
The results of an evaluation are the following:
TRUE rules, which is the list of rules that evaluate to TRUE based on the given data. These rules are returned either in the OUT parameter true_rules, which returns all of the rules that evaluate to TRUE, or in the OUT parameter true_rules_iterator, which returns each rule that evaluates to TRUE one at a time.MAYBE rules, which is the list of rules that could not be evaluated for one of the following reasons:
"x.a.b" is specified, but no value is specified for the variable "x", the attribute "a", or the attribute "a.b".simple_rules_only is specified as true, or partial data is available.Maybe rules are returned either in the OUT parameter maybe_rules, which returns all of the rules that evaluate to MAYBE, or in the OUT parameter maybe_rules_iterator, which returns each rule that evaluates to MAYBE one at a time.
The caller may specify whether the procedure returns all of the rules that evaluate to TRUE and MAYBE for the event or an iterator for rules that evaluate to TRUE and MAYBE. A true rules iterator enables the client to fetch each rule that evaluates to TRUE one at a time, and a maybe rules iterator enables the client to fetch each rule that evaluates to MAYBE one at a time.
If you use an iterator, then you use the GET_NEXT_HIT function in the DBMS_RULE package to retrieve the next rule that evaluates to TRUE or MAYBE from an iterator. Oracle recommends that you close an iterator if it is no longer needed to free resources, such as memory, used by the iterator. An iterator can be closed in the following ways:
CLOSE_ITERATOR procedure in the DBMS_RULE package is run with the iterator specified.NULL because no more rules evaluate to TRUE or MAYBE.To run the DBMS_RULE.EVALUATE procedure, a user must meet at least one of the following requirements:
EXECUTE_ON_RULE_SET privilege on the rule setEXECUTE_ANY_RULE_SET system privilege|
Note: The rules engine does not invoke any actions. An action context can be returned with each returned rule, but the client of the rules engine must invoke any necessary actions. |
See Also:
|
This function returns the next rule that evaluated to TRUE from a true rules iterator, or returns the next rule that evaluated to MAYBE from a maybe rules iterator. The function returns NULL if there are no more rules that evaluated to TRUE or MAYBE.
DBMS_RULE.GET_NEXT_HIT( iterator IN NUMBER) RETURN SYS.RE$RULE_HIT;
| Parameter | Description |
|---|---|
|
|
The iterator from which the rule that evaluated to |
This procedure requires an open iterator that was returned by an earlier call to DBMS_RULE.EVALUATE in the same session. The user who runs this procedure does not require any privileges on the rule set being evaluated.
When an iterator returns NULL, it is closed automatically. If an open iterator is no longer needed, then use the CLOSE_ITERATOR procedure in the DBMS_RULE package to close it.
See Also:
|