Skip to main content

Computed Values

Computed Values

You can insert a value into a column with a defined COMPUTECODE under these conditions:

Defined Column Value Behavior
COMPUTECODE with no related compute keywords

Value is computed and stored on INSERT. Value is not changed on UPDATE.

COMPUTECODE with COMPUTEONCHANGE

Value is computed and stored on INSERT.

Value is recomputed and stored on UPDATE.

COMPUTECODE with DEFAULT and COMPUTEONCHANGE Default value is stored on INSERT. Value is computed and stored on UPDATE.
COMPUTECODE with CALCULATED or TRANSIENT

If you insert a valid value into a calculated column, InterSystems IRIS inserts the row and increments ROWCOUNT. However, because this value is not stored, it is not inserted. When you query this column, InterSystems SQL recomputes the value and returns that value.

If a column of this type is part of a foreign key constraint, a value for this column is computed during the insert in order to perform the referential integrity check. This computed value is not stored.

If the compute code contains a programming error (for example, divide by zero), the INSERT operation fails with an SQLCODE -415 error.

For more details, see Computing a field value on INSERT or UPDATE.

FeedbackOpens in a new tab