Valid in: SQL, ESQL
Create Rule statement defines an Ingres rule. A rule executes a specified database procedure whenever a specified condition is true. For a detailed discussion of the use of rules to enforce referential integrity and security, see the Database Administrator Guide.
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|OFF|FROM|INTO [schema.]table_name
[REFERENCING [OLD AS old_corr_name] [NEW AS new_corr_name]]
[WHERE qualification]
Specifies the name of the rule. Rules cannot be defined against views, only against base tables.
Limits: The rule name must be a valid object name of no more than 32 characters that is unique within the set of rules owned by the user issuing the CREATE RULE statement.
Defines the action that fires the rule. For details, see Table_Condition.
Defines a row- or statement-level rule. For details, see Row and Statement Level Rules.
Specifies the procedure to be executed when a statement fires the rule. The procedure must exist at the time the rule is created.
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.
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.