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.
There is a minor difference in the behavior of variables declared
with
a "?" rather than with the
isSQLNullable property.
When an integer variable is set to a null value, the value of the
variable
itself is set to 0 and an associated
null flag is turned on.
When used
in an expression, EGL ignores the null flag for a variable declared
with
isSQLNullable that
is set to YES (this makes no difference with character variables).
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 result = 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 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.