The identifiers for the year-month interval ODBC C data types are:
SQL_C_INTERVAL_MONTH
SQL_C_INTERVAL_YEAR
SQL_C_INTERVAL_YEAR_TO_MONTH
The following table shows the ODBC SQL data types to which year-month interval 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 [a] SQL_VARCHAR [a] SQL_LONGVARCHAR [a] |
Column byte length >= Character byte length. Column byte length < Character byte length. [a] Data value is not a valid interval literal. |
n/a
22001 22015 |
SQL_WCHAR [a] SQL_WVARCHAR [a] SQL_WLONGVARCHAR [a] |
Column character length >= Character length of data. Column character length < Character length of data. [a] Data value is not a valid interval literal. |
n/a
22001 22015 |
SQL_TINYINT [b] SQL_SMALLINT [b] SQL_INTEGER [b] SQL_BIGINT [b] SQL_NUMERIC [b] SQL_DECIMAL [b] |
Conversion of a single-field interval did not result in truncation of whole digits. Conversion resulted in truncation of whole digits. |
n/a 22003 |
SQL_INTERVAL_MONTH SQL_INTERVAL_YEAR SQL_INTERVAL_YEAR_TO _MONTH |
Data value was converted without truncation of any fields. One or more fields of data value were truncated during conversion. |
n/a 22015 |
[a]All C interval data types can be converted to a character data type.
[b]If the type field in the interval structure is such that the interval is a single field, (SQL_YEAR or SQL_MONTH), then the interval C type can be converted to any exact numeric (SQL_TINYINT, SQL_SMALLINT, SQL_INTEGER, SQL_BIGINT, SQL_DECIMAL, or SQL_NUMERIC).
The default conversion of an interval C type is to the corresponding year-month interval SQL type.
The driver ignores the length/indicator value when converting data from the interval C data type and assumes that the size of the data buffer is the size of the interval 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.