Nullable Value Types
TODO
Var #EatsChocolate As Boolean
The variable #EatsChocolate
can have one of three values:
True
, False
, or #Null
.
Its initial value is #Null
.
To use a nullable type variable
TODO
Initial values
TODO
Var #TotalUnits As Int32
You can use null values to show something is not given or is unknown.
If you change #TotalUnits
to TotalUnits
, you cannot show that the information is not available.
To set values
TODO
#TotalUnits = 5
TODO
#TotalUnits = #Null
To get values
TODO
To compare nullable variables
When you use nullable Boolean variables in a Boolean expression, the result can be True
, False
, or #NULL
.
The truth table that follows gives results for And
and Or
.
Because #b1
and #b2
have three possible values, there are nine mixtures.
#b1 | #b2 | #b1 And #b2 | #b1 Or #b2 |
---|---|---|---|
#Null | #Null | NULL | NULL |
#Null | True | NULL | True |
#Null | False | False | NULL |
True | #Null | NULL | True |
True | True | True | True |
True | False | False | True |
False | #Null | False | NULL |
False | True | False | True |
False | False | False | False |
Nullable types and databases
TODO