Difference between revisions of "CALCULATED Column Constraint"

From Recital Documentation Wiki
Jump to: navigation, search
(Products)
Line 27: Line 27:
  
 
==Products==
 
==Products==
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
+
Recital, Recital Server
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:SQL]]
 
[[Category:SQL]]

Revision as of 16:21, 9 December 2009

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, Recital Server