Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

transaction.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  *   FILE
00004  *      pqxx/transaction.h
00005  *
00006  *   DESCRIPTION
00007  *      definition of the pqxx::Transaction class.
00008  *   pqxx::Transaction represents a database transaction
00009  *
00010  * Copyright (c) 2001-2003, Jeroen T. Vermeulen <jtv@xs4all.nl>
00011  *
00012  *-------------------------------------------------------------------------
00013  */
00014 #ifndef PQXX_TRANSACTION_H
00015 #define PQXX_TRANSACTION_H
00016 
00017 /* While you may choose to create your own Transaction object to interface to 
00018  * the database backend, it is recommended that you wrap your transaction code 
00019  * into a Transactor code instead and let the Transaction be created for you.
00020  * See pqxx/transactor.h for more about Transactor.
00021  *
00022  * If you should find that using a Transactor makes your code less portable or 
00023  * too complex, go ahead, create your own Transaction anyway.
00024  */
00025 
00026 // Usage example: double all wages
00027 //
00028 // extern Connection C;
00029 // Transaction T(C);
00030 // try
00031 // {
00032 //   T.Exec("UPDATE employees SET wage=wage*2");
00033 //   T.Commit();        // NOTE: do this inside try block
00034 // } 
00035 // catch (const exception &e)
00036 // {
00037 //   cerr << e.what() << endl;
00038 //   T.Abort();         // Usually not needed; same happens when T's life ends.
00039 // }
00040 
00041 #include "pqxx/connection.h"
00042 #include "pqxx/transactionitf.h"
00043 
00044 /* Methods tested in eg. self-test program test1 are marked with "//[t1]"
00045  */
00046 
00047 
00048 // TODO: Any user-friendliness we can add to invoking stored procedures?
00049 
00050 namespace pqxx
00051 {
00052 
00054 
00078 class PQXX_LIBEXPORT Transaction : public TransactionItf
00079 {
00080 public:
00083   explicit Transaction(Connection &, 
00084                        const PGSTD::string &Name=PGSTD::string());      //[t1]
00085 
00086   virtual ~Transaction();                                               //[t1]
00087 
00088 private:
00089   virtual void DoBegin();                                               //[t1]
00090   virtual Result DoExec(const char[]);                                  //[t1]
00091   virtual void DoCommit();                                              //[t1]
00092   virtual void DoAbort();                                               //[t13]
00093 };
00094 
00095 }
00096 
00097 #endif
00098 

Generated on Fri Feb 28 19:23:32 2003 for libpqxx by doxygen1.3-rc3