Question

I'm using poco c++ libraries version 1.4.6p1 all i'm using it to do some transactions in sql server 2012 but the transactions are not working, but it works for mysql is there any additional enhancements need to be done to support transactions?

Was it helpful?

Solution

I debugged the poco library, in the poco->ODBC->SessionImpl class the begin function which marks the start of a transaction has no implementation, where as in poco->MySQL->SessionImpl class the begin function has implementation that's why transaction works for MySQL not for SQL Server

OTHER TIPS

As of Poco 1.7.x (the latest at the time of writing) supports Transactions. Only you have to enable it explicitly. Here is a sample:

//setup your session skipped
session.setFeature("autoCommit", false);
Poco::Data::Transaction transaction(session);
std::vector<std::string> sqlList;
sqlList.push_back("DELETE FROM Table WHERE cond1='condition1'");
sqlList.push_back("DELETE FROM Table WHERE cond2='condition2'");
sqlList.push_back("DELETE FROM Table WHERE cond3='condition3'");

transaction.execute(sqlList);
transaction.commit();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top