8 #define SOCI_ODBC_SOURCE 22 position_ = position++;
29 odbcType_ = SQL_C_CHAR;
30 size =
sizeof(char) + 1;
31 buf_ =
new char[size];
35 odbcType_ = SQL_C_CHAR;
38 size = statement_.column_size(position_);
41 buf_ =
new char[size];
45 odbcType_ = SQL_C_SSHORT;
49 odbcType_ = SQL_C_SLONG;
53 if (use_string_for_bigint())
55 odbcType_ = SQL_C_CHAR;
56 size = max_bigint_length;
57 buf_ =
new char[size];
62 odbcType_ = SQL_C_SBIGINT;
63 size =
sizeof(
long long);
67 if (use_string_for_bigint())
69 odbcType_ = SQL_C_CHAR;
70 size = max_bigint_length;
71 buf_ =
new char[size];
76 odbcType_ = SQL_C_UBIGINT;
77 size =
sizeof(
unsigned long long);
81 odbcType_ = SQL_C_DOUBLE;
82 size =
sizeof(double);
85 odbcType_ = SQL_C_TYPE_TIMESTAMP;
86 size =
sizeof(TIMESTAMP_STRUCT);
87 buf_ =
new char[size];
91 odbcType_ = SQL_C_ULONG;
92 size =
sizeof(
unsigned long);
95 throw soci_error(
"Into element used with non-supported type.");
100 SQLRETURN rc = SQLBindCol(statement_.hstmt_, static_cast<SQLUSMALLINT>(position_),
101 static_cast<SQLUSMALLINT>(odbcType_), data, size, &valueLen_);
105 "into type pre_fetch");
115 bool gotData,
bool calledFromFetch,
indicator * ind)
117 if (calledFromFetch ==
true && gotData ==
false)
127 if (SQL_NULL_DATA == valueLen_)
132 "Null value fetched and no indicator defined.");
149 char *c =
static_cast<char*
>(data_);
154 std::string *s =
static_cast<std::string *
>(data_);
158 throw soci_error(
"Buffer size overflow; maybe got too large string");
163 std::tm *t =
static_cast<std::tm *
>(data_);
165 TIMESTAMP_STRUCT * ts =
reinterpret_cast<TIMESTAMP_STRUCT*
>(buf_);
167 t->tm_year = ts->year - 1900;
168 t->tm_mon = ts->month - 1;
169 t->tm_mday = ts->day;
170 t->tm_hour = ts->hour;
171 t->tm_min = ts->minute;
172 t->tm_sec = ts->second;
177 else if (type_ ==
x_long_long && use_string_for_bigint())
179 long long *ll =
static_cast<long long *
>(data_);
182 throw soci_error(
"Failed to parse the returned 64-bit integer value");
187 unsigned long long *ll =
static_cast<unsigned long long *
>(data_);
190 throw soci_error(
"Failed to parse the returned 64-bit integer value");
std::size_t const odbc_max_buffer_length
virtual void define_by_pos(int &position, void *data, details::exchange_type type)
bool is_odbc_error(SQLRETURN rc)
virtual void post_fetch(bool gotData, bool calledFromFetch, indicator *ind)