For the value of this keyword, specify (in curly braces) a line of ObjectScript code that sets the value of the property, according to the following rules:
-
To refer to this property, use {*}
Or if the SqlFieldName keyword is not specified for the property, use {propertyname} where propertyname is the property name. If the SqlFieldName keyword is specified for the property, use {sqlfieldnamevalue} where sqlfieldnamevalue is the value of that keyword.
Note that SqlFieldName is available for all object classes, although it is useful only for persistent classes.
For further information on field names in ObjectScript code, see Controlling the SQL Projection of Literal Properties in the chapter Defining and Using Literal Properties in Defining and Using Classes or see CREATE TRIGGER in the InterSystems SQL Reference.
-
Similarly, to refer to another property, if the SqlFieldName keyword is not specified for the property, use {propertyname} where propertyname is the property name. If the SqlFieldName keyword is specified for the property, use {sqlfieldnamevalue} where sqlfieldnamevalue is the value of that keyword.
-
The code can include multiple Set commands, if necessary. Blank spaces are permitted before or after the equal sign, though each entire Set statement must appear on a single line.
-
The code can refer to class methods, routines, or subroutines via the usual full syntax. Similarly, it can use ObjectScript functions and operators.
-
The code can include embedded SQL.
-
The code can include the following pseudo-field reference variables, which are translated into specific values at class compilation time:
-
{%%CLASSNAME} and {%%CLASSNAMEQ} both translate to the name of the class which projected the SQL table definition. {%%CLASSNAME} returns an unquoted string and {%%CLASSNAMEQ} returns a quoted string.
-
{%%TABLENAME} translates to the fully qualified name of the table, returned as a quoted string.
-
{%%ID} translates to the RowID name. This reference is useful when you do not know the name of the RowID field.
These names are not case-sensitive.
-
The compute code must be written in ObjectScript. To specify code in other languages, such as Python, specify a PropertyComputation class method instead. PropertyComputation is the name of the property being computed. For more details, see Computed Values.
If you specify both SqlComputeCode and a PropertyComputation method, SqlComputeCode overrides PropertyComputation.
-
The code cannot use syntax of the form ..propertyname or ..methodname()