Hello All,
PFA a test program to test boost::optional with prepared statement. If the
typedef uses boost::optional, 200 records are inserted which is wrong. If the
typedef uses std::string, 110 records are inserted which is correct.
--
Shridhar
#define SOCI_USE_BOOST
#include <soci.h>
#include <soci-postgresql.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdlib>
#undef NDEBUG
#include <cassert>
using namespace soci;
typedef std::string varchar;
void prepare(std::vector<varchar> & names,std::vector<varchar> & addresses,std::size_t n=5)
{
names.clear();addresses.clear();
for(std::size_t i=0;i<n;i++)
{
std::stringstream s;
s << "shridhar" << i;
names.push_back(s.str());
s.clear();s.str("");
s << "pune" << i ;
addresses.push_back(s.str());
}
}
int main()
{
try
{
session sql(postgresql,"dbname=test");
transaction tr(sql);
sql.once << "delete from person";
std::vector<varchar> names,addresses;
const int maxSize = 100;
prepare(names,addresses,maxSize);
statement st = (sql.prepare << "insert into person(name,address) values(:name,:address)",use(names),use(addresses));
st.execute(true);
prepare(names,addresses,10);
st.execute(true);
tr.commit();
}
catch(std::exception & e)
{
std::cout << e.what() << std::endl;
}
return 0;
}------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users