To specify when a property is recomputed, use the following syntax:
Property name As classname [ SqlComputed, SqlComputeCode=sqlcomputecode, SqlComputeOnChange = propertynames ];
Where sqlcomputecode is described in SqlComputeCode and propertynames is either a single property name or a comma-separated list of property names. This value can also include the values %%INSERT or %%UPDATE.
Note that you must use the actual property names, rather than the values given by SqlFieldname.
This keyword applies only to triggered computed properties; it is ignored for other properties. (A triggered computed property is a property for which SqlComputed is true and SqlComputeCode is specified, but for which Calculated and Transient are both false. See “Defining a Computed Property” in Using Caché Objects.)
This keyword controls the conditions under which this property is recomputed. Recomputation can result from:
The modification of any specified properties.
The occurrence of a triggering event.
If the keyword has a value of %%INSERT or %%UPDATE, then INSERT or UPDATE calls, respectively, specify event-triggered computation of the value of the field (property).
With %%INSERT, Caché computes the field value when a row is inserted into the table. Caché invokes the code specified in the SQLComputeCode keyword to set the value. If SQLComputeCode uses the same field as an input value, then Caché uses the value explicitly provided for that field; if no value is given, Cache uses the InitialExpression (if this is specified) or null (if InitialExpression is not specified).
With %%UPDATE, Caché computes the field value when a row is inserted into the table and recomputes it when a row is updated. In both cases, Caché invokes the code specified in the SQLComputeCode keyword to set the value. If SQLComputeCode uses the same field as an input value, then Caché uses the value explicitly provided for that field; if no value is given, Caché uses the previous field value.
Any event-triggered computation occurs immediately before validation and normalization (which themselves are followed by writing the value to the database).
Event-triggered computation of a field’s value may override any explicitly specified value for the property, depending on the code that computes the property’s value.
The default value for the SqlComputeOnChange keyword is an empty string.
“Property Definitions” in this book
“Defining and Using Literal Properties” in Using Caché Objects
“Working with Collections” in Using Caché Objects
“Working with Streams” in Using Caché Objects
“Defining and Using Object-Valued Properties” in Using Caché Objects
“Defining and Using Relationships” in Using Caché Objects
“Introduction to Compiler Keywords” in Using Caché Objects