Functions to obtain information on date and time data

The following table shows the DataBlade® API functions that obtain qualifier information for a DATETIME (mi_datetime) or INTERVAL (mi_interval) value.
Table 1. DataBlade API functions that obtain DATETIME or INTERVAL information
Source DataBlade API functions
For a data type mi_type_qualifier(), mi_type_precision(), mi_type_scale()
For a UDR argument mi_fp_argprec(), mi_fp_setargprec(), mi_fp_argscale(), mi_fp_setargscale()
For a UDR return value mi_fp_retprec(), mi_fp_setretprec(), mi_fp_retscale(), mi_fp_setretscale()
For a column in a row (or field in a row type) mi_column_precision(), mi_column_scale()
For an input parameter in a prepared statement mi_parameter_precision(), mi_parameter_scale()
Suppose you have a table with a single column, dt_col, of type DATETIME YEAR TO SECOND. If row_desc is a row descriptor for a row in this table, the following code fragment obtains the name, qualifier, precision, and scale for this column value.
Figure 1: Obtaining type information for a DATETIME value
MI_TYPE_DESC *col_type_desc;
MI_ROW_DESC *row_desc;
mi_string *type_name;
mi_integer type_qual;
...
col_type_desc = mi_column_typedesc(row_desc, 0);
type_name = mi_type_typename(col_type_desc);
type_qual = mi_type_qualifier(col_type_desc);
type_prec = mi_type_precision(col_type_desc);
type_scale = mi_type_scale(col_type_desc);
sprintf(type_buf,
   "column=%d: type name=%s, qualifier=%d precision=%d \
   scale=%d\n", 
   i, type_name, type_qual, type_prec, type_scale);
In the preceding code fragment, the value in the type_buf buffer would be as follows:
column=0, type name=datetime year to second, qualifier=3594 precision=14 scale=10