Preconditions and postconditions

Previous Next

The Rules Engine uses preconditions and postconditions in some optimisation techniques. These are used in corrective UPDATE constraints.

A constraint has a precondition for a given column if, in the WHERE clause of the statement, the column is compared to a constant, or to an expression evaluating to a constant, or to NULL or to NOT NULL. Clauses with subqueries and clauses containing OR are never preconditions. There may be more than one precondition: in this case the preconditions are linked by AND.

A constraint has a postcondition for a given column if that column is SET to a constant value, or to an expression evaluating to a constant, or to NULL. A SET clause setting the column to a subquery is never a postcondition. There may be several postconditions: in this case the SET clause contains two or more parts separated by commas.

Example

Consider the following SQL statement:

UPDATE    <Table>
SET       ColA =
(
          SELECT    ... 
          FROM      <Table2> 
          ... 
)
,        ColB = 'N'
WHERE    ColA IS NULL
AND      ColC = 'Y'

In this SQL statement, the clauses:

ColA IS NULL

and

ColC = 'Y'

 

are preconditions, while the clause:

ColB IS 'N'

 

is a postcondition.

NOTE: In SQL, you can write more than one SET statement using commas as separators as in the example, but you can use the following construct against Oracle only:

...SET (ColA, ColB) = (<Expr>,<Expr>)

Before corrective UPDATE constraints are evaluated, the Rules Engine looks for any preconditions and postconditions of the constraints:

MR_clip0073

 

See also

Deactivation between constraints

Deactivation between incoming data, preconditions and postconditions

Update-on-self sorting

Constraint evaluation order