TDS supports handling of null values within messages. You can
use the message set property Boolean Null
Representation to specify the value to be used for Boolean Null
representation. You can use the object properties Encoding
Null and Encoding Null Value to
control how null handling is represented for individual objects.
You
can select the Encoding Null property
from the three enumerated values NULLPadFill, NULLLogicalValue, and NULLLiteralValue:
- You should use the NULLPadFill option
only for fixed length objects. If you select this option for an object of
simple type dateTime, a null dateTime is written out, which is an empty tag
with a delimiter. (This is equivalent to selecting NullLiteralValue, with
the Encoding Null Value property
set to the empty string "".) If you select this option for an object of another
simple type, the object is filled with the value specified by the Padding Character property. If you select
this option, the Encoding Null Value property
is disabled.
If you use this option for a variable length object, the parser
does not know how many padding characters to write out, so it does not write
any. Instead, the parser writes an explicit null, with tag and delimiter but
no data value. For example:
tag1:,
is written out, where
tag1 is
the tag for the variable length element with
NULLPadFill set,
":" is
the tag data separator, and
"," is the delimiter.
- If you select the NULLLogicalValue option,
the value entered for the Encoding Null
Value property is converted to its logical value. For writing,
the logical value is written in the same way as any other value. For parsing,
the converted logical value is compared against the converted message data.
- If you select the NULLLiteralValue option,
the value entered for the Encoding Null
Value property is directly substituted as if it were a string
value. The value is case insensitive. For fixed length objects, the literal
value must be no longer than the length of the object.
If the literal value
is shorter, the Encoding Null Value is
padded (using Padding Character)
on output. On input, if the NULLLiteralValue's
length does not match the Length field,
you should set the message set level Trim
Fix Len String property so that padded nulls are correctly parsed.
The use of the Encoding Null Value property
is dependent on the value that you select for the Encoding
Null property described above. Null values are not defined for
binary types. The properties Encoding Null and Encoding Null Value are therefore not
set for binary types.