Discussion:
[soci-users] SOCI bind into a rowset pointer when using Core Interface
Isura Nirmal
2017-03-22 10:08:14 UTC
Permalink
I have following code which I try to use SOCI's core interface and get the
result to a rowset object.This code perfectly works but I dont find anyway
to get the result set directly to a rowset pointer.

int main(int argc, char* argv[])
{
std::string user = "dbuser1";
std::string password= "dbuser1";
std::string alias= "localhost:1521/ora12c";
std::string connection = "service=" + alias + " user=" + user + "
password=" + password;
soci::rowset<soci::row>* rowSet = NULL;
try
{
soci::session sociSession(soci::oracle, connection);
soci::row row;
std::vector<std::string> values;
std::string m_sql = "SELECT * FROM TEST_TABLE WHERE RECORD_STATUS
=:1 AND LOGIN_STATUS=:2";
values.push_back("0");
values.push_back("1");

soci::statement st(sociSession);
st.exchange(soci::into(row));
for(std::size_t i=0; i<values.size(); ++i)
{
st.exchange(soci::use(values[i]));
}
st.alloc();
st.prepare(m_sql);
st.define_and_bind();
st.execute(true);

//TODO get the result set to to rowSet
}

catch (soci::oracle_soci_error const &e)
{
cout << "Oracle error: " << e.err_num_
<< " " << e.what() << endl;
}
catch (exception const &e)
{
cout << "Some other error: " << e.what() << endl;
}
return 0;
}

The documentation has the section for getting an iterator like below
soci::rowset_iterator<soci::row> it(st, row) and the closest thing I could
find was exchange_for_rowset in the statement class. But there was no luck
in using that either. Is there any capability to assign the result set
directly to soci::rowset<soci::row>* in soci or do I have to iterate over
it and assign them. I am new to the Core Interface in soci and didn't find
much examples. Highly appreciate the help.






*B.A. Isura Nirmal*
<http://www.thetechhealer.com/> <https://twitter.com/isuranirmal>
<https://plus.google.com/+IsuraNirmal>
<http://lk.linkedin.com/in/isuranirmal>

Loading...