Commit 576ec1d1 by wuyang.zou

fix Use Transcation When insert table Products + promotions

parent 39cee4f1
......@@ -117,7 +117,7 @@ bool PrintOrderPromotionDB::insertOrderPromotion(OrderObject* orderObj){
// 开启数据库事务实现原子操作: 保证 tb_order_promotions: 订单促销优惠列表 同时插入成功;
// m_sqlDb.transaction(); 驱动不支持;
QSqlQuery query(m_sqlDb);
if ( !query.exec("START TRANSACTION") ) {
if ( !query.exec("begin tran") ) {
QLOG_ERROR()<<"[<<<<---PrintCupStickPosDB::insertOrderPromotion: Begin transaction Failed--->>>>]"<<m_sqlDb.lastError().text();
}
......@@ -134,9 +134,9 @@ bool PrintOrderPromotionDB::insertOrderPromotion(OrderObject* orderObj){
// Sleep(10*1000); // test sqldb transaction
// m_sqlDb.commit() and m_sqlDb.rollback() 都是不支持的;
if ( retInsCoupProm || retInsNorProm ) {
if ( !query.exec( "COMMIT" ) ) {
if ( !query.exec( "commit" ) ) {
QLOG_ERROR()<<"[<<<<---insertOrderProduct::insertOrderPromotion: Begin Commit Failed--->>>>]"<<m_sqlDb.lastError().text();
if ( !query.exec( "ROLLBACK" ) ) {
if ( !query.exec( "rollback" ) ) {
QLOG_ERROR()<<"[<<<<---insertOrderProduct::insertOrderPromotion: Begin Rollback Failed--->>>>]"<<m_sqlDb.lastError().text();
}
}
......
......@@ -130,7 +130,7 @@ bool PrintCupStickPosDB::insertOrderProduct(OrderObject* orderObj,const QString&
// 开启数据库事务实现原子操作: 保证 tb_main_prod_refinfo:父商品与子商品 同时插入成功;
// m_sqlDb.transaction(); 驱动不支持;
QSqlQuery query(m_sqlDb);
if ( !query.exec("START TRANSACTION") ) {
if ( !query.exec("begin tran") ) {
QLOG_ERROR()<<"[<<<<---PrintCupStickPosDB::insertOrderProduct: Begin transaction Failed--->>>>]"<<m_sqlDb.lastError().text();
}
......@@ -147,9 +147,9 @@ bool PrintCupStickPosDB::insertOrderProduct(OrderObject* orderObj,const QString&
// Sleep(10*1000); // test sqldb transaction
// m_sqlDb.commit() and m_sqlDb.rollback() 都是不支持的;
if ( retInsCoupProd || retInsNorProd ) {
if ( !query.exec( "COMMIT" ) ) {
if ( !query.exec( "commit" ) ) {
QLOG_ERROR()<<"[<<<<---insertOrderProduct::insertOrderProduct: Begin Commit Failed--->>>>]"<<m_sqlDb.lastError().text();
if ( !query.exec( "ROLLBACK" ) ) {
if ( !query.exec( "rollback" ) ) {
QLOG_ERROR()<<"[<<<<---insertOrderProduct::insertOrderProduct: Begin Rollback Failed--->>>>]"<<m_sqlDb.lastError().text();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment