CALCULATED Column Constraint

From Recital Documentation Wiki
Revision as of 17:17, 19 March 2009 by Yvonnemilne (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

CALCULATED

Class

Column Constraints


Purpose

Column constraint to calculate the value of a column


Syntax

CALCULATED <expr>


See Also

ALTER TABLE, CONSTRAINTS, CREATE TABLE


Description

A constraint is used to define rules that help to provide data integrity. Column constraints are specific to the column name specified. You must have ALTER privilege on the table. The table will be locked for EXCLUSIVE use during the operation.

The CALCULATED column constraint is used to calculate the value of a column whenever it is accessed. The <expr> specified must evaluate to the same data type as the target column. Specifying the CALCULATED column constraint causes the column to be read only. If the <expr> is based on other columns from the same table, these columns must have the RECALCULATE column constraint set, so that any changes to their values cause calculated fields to be recalculated.


Example

ALTER TABLE customer
ALTER COLUMN available CALCULATED limit-balance
ALTER COLUMN limit RECALCULATE
ALTER COLUMN balance RECALCULATE;


Products

Recital Database Server, Recital Mirage Server, Recital Terminal Developer