SQL to C conversion for time data

You can convert the time SQL data type, SQL_TYPE_TIME, into a C data type.

The following table shows information about converting time SQL data to C data.

Table 1. Conversion of time SQL data to C data
fCType Test rgbValue pcbValue SQLSTATE
SQL_C_CHAR cbValueMax >= 9 Data 8 000001
cbValueMax < 9 Untouched 8 22003
SQL_C_WCHAR cbValueMax >= 18 Data 16 000001
cbValueMax < 18 Untouched 16 22003
SQL_C_TYPE_TIME None2 Data 63 000001
SQL_C_TYPE_TIMESTAMP None2 Data4 163 000001
SQL_C_TYPE_ TIMESTAMP_EXT None2 Data5 203 000001
SQL_C_TYPE_TIMESTAMP_EXT_TZ7 None2 Data6 243 000001
Notes:
  1. SQLSTATE 00000 is not returned by SQLGetDiagRec(), rather it is indicated when the function returns SQL_SUCCESS.
  2. The value of cbValueMax is ignored for this conversion. The driver assumes that the size of rgbValue is the size of the C data type.
  3. This is the size of the corresponding C data type.
  4. The date fields of the TIMESTAMP_STRUCT structure are set to the current system date of the machine that the application is running, and the time fraction is set to zero.
  5. The time fields of the TIMESTAMP_STRUCT_EXT structure are set to zero.
  6. The date fields of the TIMESTAMP_STRUCT_EXT_TZ structure are set to the current system date of the machine that the application is running on, and the time fraction is set to zero.
  7. The time zone fields of the TIMESTAMP_STRUCT_EXT_TZ structure are set based on either CLIENTTIMEZONE, SESSIONTIMEZONE, or the current system time zone of the machine on which the application is running.

When the time SQL data type is converted to the character C data type, the resulting string is in the "hh:mm:ss” format.