Recursive Constraints

Previous Next

See Also

Recursive constraints are corrective constraints that cause themselves to be evaluated again, thereby creating a "loop". Recursive constraints are sometimes, but not always, an indication of poor conceptual definition.

For example, the following constraint will call itself as many times as the Max Constraint Depth deployment configuration setting in the Authorizer (default 50) allows and will then result in an error message:

UPDATE TableA

SET    ColumnA = ColumnA + 1

WHERE  ColumnB = 'ABC'

A successful recursive constraint must therefore contain some WHERE clause acting as a "stop condition". This stop condition restricts further recursion of the constraint:

UPDATE TableA

SET    ColumnA = ColumnA + 1

WHERE  ColumnB = 'ABC'

AND    Column A <= 80

Of course, if this rule has no further consequences it is much better to write:

UPDATE TableA

SET    ColumnA = 80

WHERE  ColumnB = 'ABC'

Constraint recursivity not only occurs when a single constraint causes the evaluation of itself, but also when two or more constraints cause the evaluation of each other.

Related Topics

Example: Recursive Constraint

Example: The OLD() Function and Constraint Recursivity