diff --git a/src/backends/odbc/standard-use-type.cpp b/src/backends/odbc/standard-use-type.cpp index 58883485b..f5ba919e4 100644 --- a/src/backends/odbc/standard-use-type.cpp +++ b/src/backends/odbc/standard-use-type.cpp @@ -40,7 +40,7 @@ void* odbc_standard_use_type_backend::prepare_for_bind( size = sizeof(int16_t); break; case x_uint16: - sqlType = SQL_SMALLINT; + sqlType = SQL_INTEGER; cType = SQL_C_USHORT; size = sizeof(uint16_t); break; @@ -50,9 +50,22 @@ void* odbc_standard_use_type_backend::prepare_for_bind( size = sizeof(int32_t); break; case x_uint32: - sqlType = SQL_INTEGER; - cType = SQL_C_ULONG; - size = sizeof(uint32_t); + if (use_string_for_bigint()) + { + sqlType = SQL_NUMERIC; + cType = SQL_C_CHAR; + size = max_bigint_length; + buf_ = new char[size]; + snprintf(buf_, size, "%u", + exchange_type_cast(data_)); + indHolder_ = SQL_NTS; + } + else // Normal case, use ODBC support. + { + sqlType = SQL_BIGINT; + cType = SQL_C_ULONG; + size = sizeof(uint32_t); + } break; case x_int64: if (use_string_for_bigint()) diff --git a/src/backends/odbc/vector-use-type.cpp b/src/backends/odbc/vector-use-type.cpp index 4d0343a61..8c6c60c6d 100644 --- a/src/backends/odbc/vector-use-type.cpp +++ b/src/backends/odbc/vector-use-type.cpp @@ -79,7 +79,7 @@ void* odbc_vector_use_type_backend::prepare_for_bind(SQLUINTEGER &size, break; case x_uint16: { - sqlType = SQL_SMALLINT; + sqlType = SQL_INTEGER; cType = SQL_C_USHORT; size = sizeof(uint16_t); std::vector *vp = static_cast *>(data_); @@ -102,13 +102,27 @@ void* odbc_vector_use_type_backend::prepare_for_bind(SQLUINTEGER &size, break; case x_uint32: { - sqlType = SQL_INTEGER; - cType = SQL_C_ULONG; - size = sizeof(SQLINTEGER); - std::vector *vp = static_cast *>(data_); + std::vector *vp = + static_cast *>(data_); std::vector &v(*vp); - prepare_indicators(v.size()); - data = &v[0]; + std::size_t const vsize = v.size(); + prepare_indicators(vsize); + + if (use_string_for_bigint()) + { + sqlType = SQL_NUMERIC; + cType = SQL_C_CHAR; + size = max_bigint_length; + buf_ = new char[size * vsize]; + data = buf_; + } + else // Normal case, use ODBC support. + { + sqlType = SQL_BIGINT; + cType = SQL_C_ULONG; + size = sizeof(uint32_t); + data = &v[0]; + } } break; case x_int64: