Data type descriptors and column type descriptors
- A data type descriptor holds unparameterized information, which is general information about the data type.
- A column type descriptor holds parameterized information, which is the information for the data type of a particular column.
Data type information in a type descriptor lists the DataBlade® API accessor functions that obtain information from a type descriptor. When you use type-descriptor accessor functions on parameterized data types, the results depend on which kind of type descriptor you pass into the accessor function.
- The data type descriptor, type_desc, stores the unparameterized
type information for the DATETIME data type.The following code fragment calls the mi_type_typename() and mi_type_qualifier() accessor functions on the type_desc type descriptor (which Type descriptor and column type descriptor for DATETIME field defines):
type_string = mi_type_typename(type_desc); type_scale = mi_type_qualifier(type_desc);
The call to mi_type_typename() returns the string
datetime
as the unparameterized name of the data type. The call to mi_type_qualifier() returns zero as the type qualifier. - The column type descriptor, col_type_desc, stores the parameterized
type information for the DATETIME field of row_type. The following code fragment calls the mi_type_typename() and mi_type_qualifier() accessor functions on the col_type_desc type descriptor (which Type descriptor and column type descriptor for DATETIME field defines):
type_string = mi_type_typename(col_type_desc); type_scale = mi_type_qualifier(col_type_desc);
The call to mi_type_typename() returns the stringdatetime year to second
as the parameterized name of the data type. The call to mi_type_qualifier()returns the actual DATETIME qualifier of3594
, which is the encoded qualifier value for:TU_DTENCODE(TU_YEAR, TU_SECOND)
- The data type descriptor, type_desc2, stores the unparameterized
type information for DECIMAL.The following code fragment calls the mi_type_precision() and mi_type_scale() accessor functions on the type_desc2 type descriptor (which Type descriptor and column type descriptor for DECIMAL field defines):
type_prec = mi_type_precision(type_desc2); type_scale = mi_type_scale(type_desc2);
Both the mi_type_precision() and mi_type_scale() functions return zero for the precision and scale.
- The column type descriptor, col_type_desc, stores the parameterized type
information for the DECIMAL field of row_type. The following code fragment calls the mi_type_precision() and mi_type_scale() accessor functions on the col_type_desc2 type descriptor (which Type descriptor and column type descriptor for DECIMAL field defines):
type_prec = mi_type_precision(col_type_desc2); type_scale = mi_type_scale(col_type_desc2);
The mi_type_precision() function returns the actual precision of the DECIMAL column,
6
. The mi_type_scale() function returns the actual precision scale of the DECIMAL column,3
.