ALLBASE/SQL Reference Manual (36216-90216)

346 Chapter10
SQL Statements A - D
CREATE RULE
CREATE RULE
The CREATE RULE statement defines a rule and associates it with specific kinds of data
manipulation on a particular table. The rule definition specifies the name of a procedure to
be executed when the rule fires.
Scope
ISQL or Application Programs
SQL Syntax
CREATE RULE [
Owner.
]
RuleName
AFTER
StatementType
[,...][ON
OF
FROM
INTO }[
Owner.
]
TableName
[REFERENCING {OLD AS
OldCorrellationName
NEW AS
NewCorrelationName
}[...]] [WHERE
FiringCondition
EXECUTE PROCEDURE [
OwnerName
.]
ProcedureName
[(
ParameterValue
[,...])]
[IN
DBEFileSetName
]
Parameters
[
Owner.
]
RuleName
is the name of the new rule. Two rules cannot have the same owner
and rule names.
The rule owner must be the same as the owner of the table the rule is
defined upon. The default owner name is the owner name of the table it is
being defined on. The usual default owner rules do not apply here.
StatementType
specifies which statements will cause the rule to fire for the given table.
StatementType
must be one of the following:
INSERT
UPDATE [(
ColumnName
[,...])]
DELETE
Each statement type can be listed in the CREATE RULE statement only once
for a given rule. If
ColumnNames
are specified for a
StatementType
of
UPDATE, they must exist in the table.
For UPDATE statements in which more than one column is specified, any
one of the column names listed here may be used in the UPDATE for the rule
to affect the statement. When you issue the UPDATE, it is not necessary to
specify all the
ColumnNames
in the CREATE RULE statement. At most, 1023
column names may be specified in this column name list.
[
Owner
.]
TableName
designates the table on which the rule is to operate. Rules cannot be
created on views.
OldCorrelationName
specifies the correlation name to be used within the