8 #define soci_ORACLE_SOURCE 23 #pragma warning(disable:4355) 24 #define snprintf _snprintf 32 void *&data, sb4 &size, ub2 &oracleType,
bool readOnly)
40 oracleType = SQLT_AFC;
44 buf_ =
new char[size];
49 oracleType = SQLT_INT;
53 buf_ =
new char[size];
58 oracleType = SQLT_INT;
62 buf_ =
new char[size];
67 oracleType = SQLT_FLT;
68 size =
sizeof(double);
71 buf_ =
new char[size];
79 oracleType = SQLT_STR;
81 buf_ =
new char[size];
85 oracleType = SQLT_STR;
88 buf_ =
new char[size];
92 oracleType = SQLT_DAT;
93 size = 7 *
sizeof(ub1);
94 buf_ =
new char[size];
101 oracleType = SQLT_RSET;
114 oracleType = SQLT_RDD;
127 oracleType = SQLT_BLOB;
129 blob *b =
static_cast<blob *
>(data);
142 int &position,
void *data,
exchange_type type,
bool readOnly)
144 if (statement_.boundByName_)
147 "Binding for use elements must be either by position or by name.");
156 prepare_for_bind(data, size, oracleType, readOnly);
158 sword res = OCIBindByPos(statement_.stmtp_, &bindp_,
159 statement_.session_.errhp_,
160 position++, data, size, oracleType,
161 &indOCIHolder_, 0, 0, 0, 0, OCI_DEFAULT);
162 if (res != OCI_SUCCESS)
167 statement_.boundByPos_ =
true;
171 std::string
const &name,
void *data,
exchange_type type,
bool readOnly)
173 if (statement_.boundByPos_)
176 "Binding for use elements must be either by position or by name.");
185 prepare_for_bind(data, size, oracleType, readOnly);
187 sword res = OCIBindByName(statement_.stmtp_, &bindp_,
188 statement_.session_.errhp_,
189 reinterpret_cast<text*>(const_cast<char*>(name.c_str())),
190 static_cast<sb4
>(name.size()),
191 data, size, oracleType,
192 &indOCIHolder_, 0, 0, 0, 0, OCI_DEFAULT);
193 if (res != OCI_SUCCESS)
198 statement_.boundByName_ =
true;
209 buf_[0] = *
static_cast<char *
>(data_);
215 *
static_cast<short *
>(
static_cast<void *
>(buf_)) = *
static_cast<short *
>(data_);
221 *
static_cast<int *
>(
static_cast<void *
>(buf_)) = *
static_cast<int *
>(data_);
226 size_t const size = 100;
227 snprintf(buf_, size,
"%" LL_FMT_FLAGS "d", *static_cast<long long *>(data_));
232 size_t const size = 100;
233 snprintf(buf_, size,
"%" LL_FMT_FLAGS "u", *static_cast<unsigned long long *>(data_));
239 *
static_cast<double *
>(
static_cast<void *
>(buf_)) = *
static_cast<double *
>(data_);
244 std::string *s =
static_cast<std::string *
>(data_);
247 std::size_t
const bufSize = 32769;
248 std::size_t
const sSize = s->size();
249 std::size_t
const toCopy =
250 sSize < bufSize -1 ? sSize + 1 : bufSize - 1;
251 strncpy(buf_, s->c_str(), toCopy);
257 std::tm *t =
static_cast<std::tm *
>(data_);
258 ub1* pos =
reinterpret_cast<ub1*
>(buf_);
260 *pos++ =
static_cast<ub1
>(100 + (1900 + t->tm_year) / 100);
261 *pos++ =
static_cast<ub1
>(100 + t->tm_year % 100);
262 *pos++ =
static_cast<ub1
>(t->tm_mon + 1);
263 *pos++ =
static_cast<ub1
>(t->tm_mday);
264 *pos++ =
static_cast<ub1
>(t->tm_hour + 1);
265 *pos++ =
static_cast<ub1
>(t->tm_min + 1);
266 *pos =
static_cast<ub1
>(t->tm_sec + 1);
283 if (ind != NULL && *ind ==
i_null)
309 const char original = *
static_cast<char *
>(data_);
310 const char bound = buf_[0];
312 if (original != bound)
314 throw soci_error(
"Attempted modification of const use element");
321 const short original = *
static_cast<short *
>(data_);
322 const short bound = *
static_cast<short *
>(
static_cast<void *
>(buf_));
324 if (original != bound)
326 throw soci_error(
"Attempted modification of const use element");
333 const int original = *
static_cast<int *
>(data_);
334 const int bound = *
static_cast<int *
>(
static_cast<void *
>(buf_));
336 if (original != bound)
338 throw soci_error(
"Attempted modification of const use element");
345 long long const original = *
static_cast<long long *
>(data_);
346 long long const bound = std::strtoll(buf_, NULL, 10);
348 if (original != bound)
350 throw soci_error(
"Attempted modification of const use element");
357 unsigned long long const original = *
static_cast<unsigned long long *
>(data_);
358 unsigned long long const bound = std::strtoull(buf_, NULL, 10);
360 if (original != bound)
362 throw soci_error(
"Attempted modification of const use element");
369 const double original = *
static_cast<double *
>(data_);
370 const double bound = *
static_cast<double *
>(
static_cast<void *
>(buf_));
372 if (original != bound)
374 throw soci_error(
"Attempted modification of const use element");
380 std::string & original = *
static_cast<std::string *
>(data_);
381 if (original != buf_)
385 throw soci_error(
"Attempted modification of const use element");
396 std::tm & original = *
static_cast<std::tm *
>(data_);
399 ub1 *pos =
reinterpret_cast<ub1*
>(buf_);
401 bound.tm_year = (*pos++ - 100) * 100;
402 bound.tm_year += *pos++ - 2000;
403 bound.tm_mon = *pos++ - 1;
404 bound.tm_mday = *pos++;
405 bound.tm_hour = *pos++ - 1;
406 bound.tm_min = *pos++ - 1;
407 bound.tm_sec = *pos++ - 1;
409 if (original.tm_year != bound.tm_year ||
410 original.tm_mon != bound.tm_mon ||
411 original.tm_mday != bound.tm_mday ||
412 original.tm_hour != bound.tm_hour ||
413 original.tm_min != bound.tm_min ||
414 original.tm_sec != bound.tm_sec)
418 throw soci_error(
"Attempted modification of const use element");
425 std::mktime(&original);
447 if (indOCIHolder_ == 0)
451 else if (indOCIHolder_ == -1)
467 OCIHandleFree(bindp_, OCI_HTYPE_DEFINE);
virtual void bind_by_name(std::string const &name, void *data, details::exchange_type type, bool readOnly)
details::statement_backend * get_backend()
details::rowid_backend * get_backend()
void throw_oracle_soci_error(sword res, OCIError *errhp)
virtual void post_use(bool gotData, indicator *ind)
void prepare_for_bind(void *&data, sb4 &size, ub2 &oracleType, bool readOnly)
details::blob_backend * get_backend()
virtual void bind_by_pos(int &position, void *data, details::exchange_type type, bool readOnly)
virtual void pre_use(indicator const *ind)