Andrew Grafham
2014-03-19 11:59:04 UTC
Hi,
Should reading a Clob/Text field into a vector work in Soci 3.2.2 with ODBC
connecting to SQL server? I'm compiling using visual studio 2013 and MingW,
and the code crashes with both.
If I change the SQL to cast the Clob field to a Varchar, the problem goes
away, and the code works fine with MySQL.
The code I'm using is :-
#include <string>
#include <soci.h>
#include <iostream>
using namespace soci;
using namespace std;
int main()
{
try
{
session dbConnection("odbc", "xxxx");
std::string sql = "select colbfield from table where id = :a";
const int BATCH_SIZE = 300;
int id = 0;
std::vector<std::string> vClob(BATCH_SIZE);
std::vector<indicator> inds(BATCH_SIZE);
statement st = (dbConnection.prepare << sql, into(vClob, inds),
use(id));
st.execute();
while (st.fetch())
{
for (int i = 0; i < vClob.size(); i++)
std::cout << "Value = " << vClob.at(i) << std::endl;
vClob.resize(BATCH_SIZE);
}
}
catch (exception const &e)
{
std::cout << "Error: " << e.what() << '\n';
}
}
Should reading a Clob/Text field into a vector work in Soci 3.2.2 with ODBC
connecting to SQL server? I'm compiling using visual studio 2013 and MingW,
and the code crashes with both.
If I change the SQL to cast the Clob field to a Varchar, the problem goes
away, and the code works fine with MySQL.
The code I'm using is :-
#include <string>
#include <soci.h>
#include <iostream>
using namespace soci;
using namespace std;
int main()
{
try
{
session dbConnection("odbc", "xxxx");
std::string sql = "select colbfield from table where id = :a";
const int BATCH_SIZE = 300;
int id = 0;
std::vector<std::string> vClob(BATCH_SIZE);
std::vector<indicator> inds(BATCH_SIZE);
statement st = (dbConnection.prepare << sql, into(vClob, inds),
use(id));
st.execute();
while (st.fetch())
{
for (int i = 0; i < vClob.size(); i++)
std::cout << "Value = " << vClob.at(i) << std::endl;
vClob.resize(BATCH_SIZE);
}
}
catch (exception const &e)
{
std::cout << "Error: " << e.what() << '\n';
}
}