SOCI Logo Get SOCI at SourceForge.net. Fast, secure and Free Open Source software downloads

transaction.cpp

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2004-2008 Maciej Sobczak
00003 // Distributed under the Boost Software License, Version 1.0.
00004 // (See accompanying file LICENSE_1_0.txt or copy at
00005 // http://www.boost.org/LICENSE_1_0.txt)
00006 //
00007 
00008 #define SOCI_SOURCE
00009 #include "transaction.h"
00010 #include "error.h"
00011 
00012 using namespace soci;
00013 
00014 transaction::transaction(session & sql)
00015     : handled_(false), sql_(sql)
00016 {
00017     sql_.begin();
00018 }
00019 
00020 transaction::~transaction()
00021 {
00022     if (handled_ == false)
00023     {
00024         try
00025         {
00026             rollback();
00027         }
00028         catch (...) {}
00029     }
00030 }
00031 
00032 void transaction::commit()
00033 {
00034     if (handled_)
00035     {
00036         throw soci_error("The transaction object cannot be handled twice.");
00037     }
00038 
00039     sql_.commit();
00040     handled_ = true;
00041 }
00042 
00043 void transaction::rollback()
00044 {
00045     if (handled_)
00046     {
00047         throw soci_error("The transaction object cannot be handled twice.");
00048     }
00049 
00050     sql_.rollback();
00051     handled_ = true;
00052 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
SourceForge Logo

Generated on Sun Oct 3 2010 17:42:17 for EXTRAS-SOCI by Doxygen 1.7.1