Convert a locale-specific string
Conversion function | Unconverted form | Converted form: ESQL/C data type | Converted form: DataBlade® API data type |
---|---|---|---|
ifx_gl_convert_number() | Number string | decimal (dec_t) | mi_decimal |
ifx_gl_convert_money() | Money string | decimal (dec_t) | mi_decimal |
ifx_gl_convert_date() | Date string | date (long int) | mi_date |
ifx_gl_convert_datetime() | Date/time string | datetime (dtime_t) | mi_datetime |
The formatting directives in the format string tell the conversion functions what conversions to perform on the locale-specific string. To process a formatting directive, a conversion function consults the appropriate category in the current locale to obtain any locale-specific formats and then converts the resulting value to an internal representation that can be stored in a database.
"1,450"
to its hexadecimal equivalent
in an mi_decimal value:mi_decimal num_val;
...
if ( ifx_gl_convert_number(&num_val, "1,450","%0x") != 0 )
/* handle error */
In the current locale, the thousands separator is defined as the comma (,) symbol. Therefore, the ifx_gl_convert_number() function must correctly interpret the comma in the number string so that it can convert this string to the hexadecimal equivalent of the value 1450 and store the result in the mi_decimal value, num_val.