Warning, file /sdk/codevis/thirdparty/soci/src/core/transaction.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // 0002 // Copyright (C) 2004-2008 Maciej Sobczak 0003 // Distributed under the Boost Software License, Version 1.0. 0004 // (See accompanying file LICENSE_1_0.txt or copy at 0005 // http://www.boost.org/LICENSE_1_0.txt) 0006 // 0007 0008 #define SOCI_SOURCE 0009 #include "soci/transaction.h" 0010 #include "soci/error.h" 0011 0012 using namespace soci; 0013 0014 transaction::transaction(session& sql) 0015 : handled_(false), sql_(sql) 0016 { 0017 sql_.begin(); 0018 } 0019 0020 transaction::~transaction() 0021 { 0022 if (handled_ == false) 0023 { 0024 try 0025 { 0026 rollback(); 0027 } 0028 catch (...) 0029 {} 0030 } 0031 } 0032 0033 void transaction::commit() 0034 { 0035 if (handled_) 0036 { 0037 throw soci_error("The transaction object cannot be handled twice."); 0038 } 0039 0040 sql_.commit(); 0041 handled_ = true; 0042 } 0043 0044 void transaction::rollback() 0045 { 0046 if (handled_) 0047 { 0048 throw soci_error("The transaction object cannot be handled twice."); 0049 } 0050 0051 sql_.rollback(); 0052 handled_ = true; 0053 }