Boolean binary representation
The SQL BOOLEAN data type holds the internal (binary) format of
a Boolean value. This value is a single-byte representation of Boolean
data, as the following table shows.
Boolean value | Binary representation |
---|---|
True | \1 |
False | \0 |
The BOOLEAN data type is a predefined opaque type (an opaque data
type that HCL Informix® defines).
Its external format is the Boolean text representation that Text representation of Boolean
data shows.
Its internal format consists of the values that the preceding table
shows.
Tip: The internal format of the BOOLEAN data type
is often referred to as its binary representation.
The DataBlade® API supports the SQL BOOLEAN data type with the mi_boolean data type. Therefore, the mi_boolean data type also holds the binary representation of a Boolean value.
An mi_boolean value is one byte on all computer architectures; therefore, it can fit into an MI_DATUM structure. You can pass mi_boolean data by value in C UDRs.
In client LIBMI applications, you must pass all data by reference, including mi_boolean values.
In a Windows™ environment,
because an mi_boolean value is smaller than the size of an MI_DATUM structure,
the DataBlade®
API cast
promotes the value to the size of MI_DATUM when you copy the
value into an MI_DATUM structure. When you obtain the mi_boolean value
from an MI_DATUM structure, you need to reverse the cast promotion
to ensure that your value is correct.
MI_DATUM datum;
mi_boolean bool_val;
...
bool_val = (char) datum;
Alternatively, you can declare an mi_integer value to hold the Boolean value.