18 #pragma warning(disable:4355) 26 : session_(s), refCount_(1), row_(0),
27 fetchSize_(1), initialFetchSize_(1),
28 alreadyDescribed_(false)
79 for (std::vector<details::standard_use_type*>::iterator it =
80 values.
uses_.begin(); it != values.
uses_.end(); ++it)
86 std::string
const& useName = (*it)->get_name();
91 int position =
static_cast<int>(
uses_.size());
92 (*it)->bind(*
this, position);
99 std::string
const placeholder =
":" + useName;
101 std::size_t pos =
query_.find(placeholder);
102 while (pos != std::string::npos)
106 const char nextChar = (pos + placeholder.size()) <
query_.size() ?
107 query_[pos + placeholder.size()] :
'\0';
109 if (std::isalnum(nextChar))
113 pos =
query_.find(placeholder, pos + placeholder.size());
117 int position =
static_cast<int>(
uses_.size());
118 (*it)->bind(*
this, position);
119 uses_.push_back(*it);
126 if (pos == std::string::npos)
137 for (std::size_t i = ++cnt; i != values.
uses_.size(); ++i)
148 std::size_t
const isize =
intos_.size();
149 for (std::size_t i = isize; i != 0; --i)
151 intos_[i - 1]->clean_up();
157 for (std::size_t i = ifrsize; i != 0; --i)
164 std::size_t
const usize =
uses_.size();
165 for (std::size_t i = usize; i != 0; --i)
167 uses_[i - 1]->clean_up();
173 for (std::size_t i = 0; i != indsize; ++i)
198 int definePosition = 1;
199 std::size_t
const isize =
intos_.size();
200 for (std::size_t i = 0; i != isize; ++i)
202 intos_[i]->define(*
this, definePosition);
211 int bindPosition = 1;
212 std::size_t
const usize =
uses_.size();
213 for (std::size_t i = 0; i != usize; ++i)
215 uses_[i]->bind(*
this, bindPosition);
222 for (std::size_t i = 0; i != isize; ++i)
230 std::size_t
const isize =
intos_.size();
231 for (std::size_t i = isize; i != 0; --i)
233 intos_[i - 1]->clean_up();
237 for (std::size_t i = ifrsize; i != 0; --i)
242 std::size_t
const usize =
uses_.size();
243 for (std::size_t i = usize; i != 0; --i)
245 uses_[i - 1]->clean_up();
257 throw soci_error(
"Vectors of size 0 are not allowed.");
267 std::size_t
const bindSize =
uses_size();
272 "Bulk insert/update and bulk select not allowed in same query");
287 if (withDataExchange)
297 if (static_cast<int>(bindSize) > num)
299 num =
static_cast<int>(bindSize);
305 bool gotData =
false;
354 bool gotData =
false;
357 std::size_t
const newFetchSize =
intos_size();
364 "Increasing the size of the output vector is not supported.");
366 else if (newFetchSize == 0)
417 std::size_t
const isize =
intos_.size();
418 for (std::size_t i = 0; i != isize; ++i)
422 intos_size =
intos_[i]->size();
424 else if (intos_size !=
intos_[i]->size())
426 std::ostringstream msg;
427 msg <<
"Bind variable size mismatch (into[" 428 <<
static_cast<unsigned long>(i) <<
"] has size " 429 << static_cast<unsigned long>(
intos_[i]->size())
430 <<
", into[0] has size " 431 << static_cast<unsigned long>(intos_size);
440 std::size_t usesSize = 0;
441 std::size_t
const usize =
uses_.size();
442 for (std::size_t i = 0; i != usize; ++i)
446 usesSize =
uses_[i]->size();
450 throw soci_error(
"Vectors of size 0 are not allowed.");
453 else if (usesSize !=
uses_[i]->size())
455 std::ostringstream msg;
456 msg <<
"Bind variable size mismatch (use[" 457 <<
static_cast<unsigned long>(i) <<
"] has size " 458 << static_cast<unsigned long>(
uses_[i]->size())
459 <<
", use[0] has size " 460 << static_cast<unsigned long>(usesSize);
477 if (upperBound != 0 && upperBound < static_cast<std::size_t>(rows))
479 rows =
static_cast<int>(upperBound);
482 std::size_t
const isize =
intos_.size();
483 for (std::size_t i = 0; i != isize; ++i)
485 intos_[i]->resize((std::size_t)rows);
488 return rows > 0 ?
true :
false;
493 std::size_t
const isize =
intos_.size();
494 for (std::size_t i = 0; i != isize; ++i)
502 std::size_t
const isize =
intos_.size();
503 for (std::size_t i = 0; i != isize; ++i)
509 for (std::size_t i = 0; i != ifrsize; ++i)
517 std::size_t
const usize =
uses_.size();
518 for (std::size_t i = 0; i != usize; ++i)
531 for (std::size_t i = 0; i != ifrsize; ++i)
536 std::size_t
const isize =
intos_.size();
537 for (std::size_t i = 0; i != isize; ++i)
539 intos_[i]->post_fetch(gotData, calledFromFetch);
547 for (std::size_t i =
uses_.size(); i != 0; --i)
549 uses_[i-1]->post_use(gotData);
561 void statement_impl::bind_into<dt_string>()
563 into_row<std::string>();
567 void statement_impl::bind_into<dt_double>()
573 void statement_impl::bind_into<dt_integer>()
579 void statement_impl::bind_into<dt_long_long>()
581 into_row<long long>();
585 void statement_impl::bind_into<dt_unsigned_long_long>()
587 into_row<unsigned long long>();
591 void statement_impl::bind_into<dt_date>()
601 for (
int i = 1; i <= numcols; ++i)
604 std::string columnName;
615 bind_into<dt_string>();
618 bind_into<dt_double>();
621 bind_into<dt_integer>();
624 bind_into<dt_long_long>();
627 bind_into<dt_unsigned_long_long>();
630 bind_into<dt_date>();
633 std::ostringstream msg;
634 msg <<
"db column type " << dtype
635 <<
" not supported for dynamic selects"<<std::endl;
652 "Only one Row element allowed in a single statement.");
standard_use_type_backend * make_use_type_backend()
statement_impl(session &s)
bool execute(bool withDataExchange=false)
virtual vector_into_type_backend * make_vector_into_type_backend()=0
virtual exec_fetch_result execute(int number)=0
std::vector< indicator * > indicators_
void log_query(std::string const &query)
int definePositionForRow_
vector_into_type_backend * make_vector_into_type_backend()
virtual void describe_column(int colNum, data_type &dtype, std::string &column_name)=0
into_type_vector intosForRow_
void set_got_data(bool gotData)
virtual standard_use_type_backend * make_use_type_backend()=0
vector_use_type_backend * make_vector_use_type_backend()
virtual void clean_up()=0
std::string get_query() const
std::size_t initialFetchSize_
void prepare(std::string const &query, statement_type eType=st_repeatable_query)
virtual long long get_affected_rows()=0
standard_into_type_backend * make_into_type_backend()
std::string rewrite_for_procedure_call(std::string const &query)
long long get_affected_rows()
virtual exec_fetch_result fetch(int number)=0
bool resize_intos(std::size_t upperBound=0)
soci::details::statement_backend * backEnd_
void add_unused(details::use_type_base *u, indicator *i)
void post_fetch(bool gotData, bool calledFromFetch)
std::vector< indicator * > indicators_
details::statement_backend * make_statement_backend()
std::vector< details::standard_use_type * > uses_
virtual vector_use_type_backend * make_vector_use_type_backend()=0
virtual standard_into_type_backend * make_into_type_backend()=0
ref_counted_prepare_info * get_prepare_info() const
void post_use(bool gotData)
bool get_uppercase_column_names() const
virtual int prepare_for_describe()=0
virtual int get_number_of_rows()=0
void uppercase_column_names(bool forceToUpper)
virtual void prepare(std::string const &query, statement_type eType)=0
void set_data_type(data_type dataType)
void set_name(std::string const &name)
void add_properties(column_properties const &cp)
virtual std::string rewrite_for_procedure_call(std::string const &query)=0