MDAC 2.5 SDK - ODBC Programmer's Reference
Appendix D: Data Types


 

C to SQL: Time

The identifier for the time ODBC C data type is:

SQL_C_TYPE_TIME

The following table shows the ODBC SQL data types to which time C data may be converted. For an explanation of the columns and terms in the table, see "Converting Data from C to SQL Data Types."

SQL type identifier Test SQLSTATE
SQL_CHAR
SQL_VARCHAR
SQL_LONGVARCHAR
Column byte length >= 8

Column byte length < 8

Data value is not a valid time

n/a

22001

22008

SQL_WCHAR
SQL_WVARCHAR
SQL_WLONGVARCHAR
Column character length >= 8

Column character length < 8

Data value is not a valid time

n/a

22001

22008

SQL_TYPE_TIME Data value is a valid time

Data value is not a valid time

n/a

22007

SQL_TYPE_TIMESTAMP Data value is a valid time[a]

Data value is not a valid time

n/a

22007


[a]   The date portion of the timestamp is set to the current date, and the fractional seconds portion of the timestamp is set to zero.

For information about what values are valid in a SQL_C_TYPE_TIME structure, see the section "C Data Types," earlier in this appendix.

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

The driver ignores the length/indicator value when converting data from the time C data type and assumes that the size of the data buffer is the size of the time C data type. The length/indicator value is passed in the StrLen_or_Ind argument in SQLPutData and in the buffer specified with the StrLen_or_IndPtr argument in SQLBindParameter. The data buffer is specified with the DataPtr argument in SQLPutData and the ParameterValuePtr argument in SQLBindParameter.