The isSQLNullable property indicates
whether the field can be set to a null value. The property is available
only for fields in an SQL record. Valid values are NO (the default)
and YES.
EGL maintains this property for compatibility with earlier versions.
For new code, use the "?" type extension character to indicate a nullable
variable. For more information, see Type extension characters and Null values and the nullable type.
Variables made nullable with a "?" are slightly different than
variables made nullable with {
isSqlNullable =
YES}. When the nullable variable has a null value and is used in an
expression with more than one operand, it has the following value:
- Null if it was declared with a "?". EGL honors the null flag.
- Not null if it was declared with {isSqlNullable =
YES}. In this case, EGL ignores the null flag and the value is zero,
blanks, the current date, or the current time. This behavior allows
compatibility with earlier versions.
Consider the following examples:
Record mySQLRecord type SQLRecord
anInt INT {isSQLNullable = YES};
end
...
myRec mySQLRecord;
result, anotherInt INT?;
myRec.anINT = NULL;
result = myRec.anInt + 1;
Here the result is 1 because
EGL ignores the null flag when evaluating the expression.
anotherInt INT? = NULL;
result = anotherInt + 1;
Here the result is
a null value because EGL takes the null flag into account (if any
operand has a null value, the result of the numeric expression is
null).
If a given field in an SQL record is nullable, the following features
are available:
- The field can accept a null value from an SQL database table.
- An assignment can null the field. This action has the side effect
of initializing the field, as described in Data initialization.
- Any logical expression can test whether the field is set to null,
or whether data received from a database was truncated.