transaction.cpp
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2008 Maciej Sobczak
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 //
7 
8 #define SOCI_SOURCE
9 #include "transaction.h"
10 #include "error.h"
11 
12 using namespace soci;
13 
15  : handled_(false), sql_(sql)
16 {
17  sql_.begin();
18 }
19 
21 {
22  if (handled_ == false)
23  {
24  try
25  {
26  rollback();
27  }
28  catch (...)
29  {}
30  }
31 }
32 
34 {
35  if (handled_)
36  {
37  throw soci_error("The transaction object cannot be handled twice.");
38  }
39 
40  sql_.commit();
41  handled_ = true;
42 }
43 
45 {
46  if (handled_)
47  {
48  throw soci_error("The transaction object cannot be handled twice.");
49  }
50 
51  sql_.rollback();
52  handled_ = true;
53 }
session & sql_
Definition: transaction.h:29
transaction(session &sql)
Definition: transaction.cpp:14


asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:41