Syntax
The CREATE RULE statement has the following format:
[EXEC SQL] CREATE RULE [schema.]rule_name table_condition
[FOR EACH {ROW | STATEMENT}]
EXECUTE PROCEDURE [schema.]proc_name[(parameter = value
{, parameter = value})]
The table_condition has the following format:
BEFORE|AFTER statement_type {, statement_type} ON|OF|FROM|INTO [schema.]table_name
[REFERENCING [OLD AS old_corr_name] [NEW AS new_corr_name]]
[WHERE qualification]
Note: The keyword TRIGGER can be used as an alias for RULE.
rule_name
Specifies the name of the rule.
Rules can be defined against base tables and against views if the view is updatable. For restrictions, see
Create View (see page
CREATE VIEW).
Limits: The rule name must be a
valid object name (see page
Object Naming Rules) that is unique within the set of rules owned by the user issuing the CREATE RULE statement.
table_condition
Defines the action that fires the rule. For details, see
Table_Condition (see page
Table_Condition).
FOR EACH ROW|STATEMENT
proc_name
Specifies the procedure to be executed when a statement fires the rule. The procedure must exist at the time the rule is created. For details, see
Procedure Execution in Create Rule (see page
Procedure Execution in Create Rule).
parameter
Specifies one or more values to be passed to the procedure. Not all of the parameters appearing in the definition of the invoked procedure have to be included. However, those that are included must match in name and data type. Parameters can be specified using host language variables. Parameters cannot be passed by reference to a procedure that is executed by a rule.
value
Contains a constant or an old or new value in the row that caused the rule to fire. Constant values cannot contain function expressions. If value represents a row value, it must be qualified by a correlation name. For details, see the description of the referencing clause.