8 #define SOCI_DB2_SOURCE 20 void *data, SQLLEN &size, SQLSMALLINT &sqlType, SQLSMALLINT &cType)
26 sqlType = SQL_SMALLINT;
31 sqlType = SQL_INTEGER;
37 cType = SQL_C_SBIGINT;
38 size =
sizeof(
long long);
42 cType = SQL_C_UBIGINT;
43 size =
sizeof(
unsigned long long);
48 size =
sizeof(double);
56 size =
sizeof(char) + 1;
58 char *c =
static_cast<char*
>(data);
68 std::string* s =
static_cast<std::string*
>(data);
69 sqlType = SQL_LONGVARCHAR;
73 strncpy(buf, s->c_str(), size);
79 sqlType = SQL_TIMESTAMP;
80 cType = SQL_C_TIMESTAMP;
81 buf =
new char[
sizeof(TIMESTAMP_STRUCT)];
82 std::tm *t =
static_cast<std::tm *
>(data);
88 TIMESTAMP_STRUCT * ts =
reinterpret_cast<TIMESTAMP_STRUCT*
>(buf);
90 ts->year =
static_cast<SQLSMALLINT
>(t->tm_year + 1900);
91 ts->month =
static_cast<SQLUSMALLINT
>(t->tm_mon + 1);
92 ts->day =
static_cast<SQLUSMALLINT
>(t->tm_mday);
93 ts->hour =
static_cast<SQLUSMALLINT
>(t->tm_hour);
94 ts->minute =
static_cast<SQLUSMALLINT
>(t->tm_min);
95 ts->second =
static_cast<SQLUSMALLINT
>(t->tm_sec);
109 return buf ? buf : data;
117 throw soci_error(
"Binding for use elements must be either by position or by name.");
123 this->position = position++;
127 std::string
const &name,
void *data,
exchange_type type,
bool )
131 throw soci_error(
"Binding for use elements must be either by position or by name.");
138 for (std::vector<std::string>::iterator it = statement_.names.begin();
139 it != statement_.names.end(); ++it)
153 this->position = position;
157 std::ostringstream ss;
158 ss <<
"Unable to find name '" << name <<
"' to bind to";
170 void *sqlData = prepare_for_bind(data, size, sqlType, cType);
172 SQLRETURN cliRC = SQLBindParameter(statement_.hStmt,
173 static_cast<SQLUSMALLINT>(position),
175 cType, sqlType, size, 0, sqlData, size, &ind);
177 if (cliRC != SQL_SUCCESS)
183 if (ind_ptr != NULL && *ind_ptr ==
i_null)
void pre_use(indicator const *ind)
void bind_by_name(std::string const &name, void *data, details::exchange_type type, bool readOnly)
void post_use(bool gotData, indicator *ind)
void * prepare_for_bind(void *data, SQLLEN &size, SQLSMALLINT &sqlType, SQLSMALLINT &cType)
void bind_by_pos(int &position, void *data, details::exchange_type type, bool readOnly)