SOCI / soci

Official repository of the SOCI - The C++ Database Access Library
http://soci.sourceforge.net/
Boost Software License 1.0
1.37k stars 472 forks source link

What is most efficient way to execute ODBC stored procedure? #1075

Open dezmen3 opened 10 months ago

dezmen3 commented 10 months ago

What is most efficient way to execute ODBC stored procedure? Currently I'm using this way:

char szQuery[512]{};
uint32_t nID = 5316;
sprintf_s(szQuery, "{CALL pSelect_Data(%d)}", nID );
soci::rowset<soci::row> rs = (pDB->prepare << szQuery);

for (soci::rowset<soci::row>::const_iterator it = rs.begin(); it != rs.end(); ++it)
{
 //do something with row result like soci::row const& row = *it;

}

This was the only way for me to run stored procedure and get some results instead of dropping into soci_error exception. But the reason I ask - sometimes when I call procedure it can actually give me empty result, while it shouldn't. It happens very randomly, can be at any point, like after few minutes, hours of looping on remote application.