19.5.4 a_rdb_CNV_charTIME() (convert to TIME-type data)
- Organization of this subsection
(1) Function
This CLI function converts character string data in C or C++ to SQL TIME-type data. The following figure shows an example of conversion from character string data to TIME-type data.
- Important
-
The character string data before conversion must be in the predefined input representation that represents time. For details about the predefined input representation for time, see the topic Predefined character-string representations in the manual HADB SQL Reference.
- Example:
-
The character string data that represents 11:03:58.123 must be in the following format:
11:03:58.123
(2) Format
#include <adbcnv.h> signed short a_rdb_CNV_charTIME ( char *char_Data, /* In */ unsigned short char_Length, /* In */ unsigned short TIME_Scale, /* In */ unsigned char *TIME_Data, /* Out */ unsigned short BufferLength, /* In */ void *Option /* In */ )
(3) Arguments
- char_Data
-
Specifies the start address of the area where the character string data before conversion (character string data in C or C++) is stored.
- char_Length
-
Specifies the length (in bytes) of the character string data before conversion. Specify a value in the range from 8 to 8 + TIME_Scale value + 1.
- TIME_Scale
-
Specifies the fractional seconds precision for the TIME-type data after conversion. Specify 0, 3, 6, 9, or 12.
- TIME_Data
-
Specifies the start address of the area where the TIME-type data after conversion is to be stored.
- BufferLength
-
Specifies the length (in bytes) of the area for storing the TIME-type data after conversion. Specify 3 + ↑value of TIME_Scale ÷ 2↑.
- Option
-
Specifies NULL. Any value that is specified is ignored.
(4) Return value
-
If a_rdb_CNV_charTIME() terminates normally, a_rdb_RC_CNV_SUCCESS is returned.
-
If an error occurs, the error code is returned as the return value. For details about the error code, see 19.8 Return values of the CLI functions.
(5) Notes
-
You must ensure that there is no overlap between the area for storing the data before conversion (char_Data) and the area for storing the data after conversion (TIME_Data).
-
The character string data before conversion is converted to TIME-type data, and then stored from the beginning of the storage area. If the fractional seconds precision for the character string data to be converted is not 3, 6, 9, or 12, zeros are padded to the right of the data until the fractional seconds precision specified for TIME_Scale is reached.