CommitTransaction
CommitTransaction executes the transaction log file, releasing all object locks if releaseObjectLocks is true else the current transaction will retain all the objects lock making CommitTransaction funtion like a save point.unsigned __int64 CommitTransaction( bool releaseObjectLocks = true );
Parameters
releaseObjectLocks | if this is set to false, this method acts as a save point, committing all adds, edits and deletes, but not releasing any object locks. |
Return Values
If the method succeeds, the return value is zero else see error codes for more details.Remarks
- If this method is not called before EndTransaction or CloseDatabase, then the transaction is aborted.
- Then releaseObjectLocks is set true, the object within the table handles are removes so any call to ReadObject or DeleteObject using CODBPP::NEXT or CODBPP::PREVIOUS will fail.
Example Use
- C++
#include "ODBPP.h" int wmain(int argc, wchar_t* argv[]) { unsigned __int64 error; const char16_t *message; CODBPP database; CODBPP::Object object; struct FixedObject{ int First; double Second; } *fixedObject; unsigned int tableID = 1; if((error = database.BeginTransaction()) == NO_ERROR && (error = database.OpenTable(tableID)) == NO_ERROR && (error = database.NewObject(tableID,&object)) == NO_ERROR){ fixedObject = (struct FixedObject*)object.fixed; fixedObject->First = 456; fixedObject->Second = 456.789; if((error = database.AddObject(tableID)) == NO_ERROR){ error = database.CommitTransaction(); } if(error && database.GetErrorMessage(&message) == NO_ERROR) MessageBox(message); database.EndTransaction(); return NO_ERROR; }
Also See
AbortTransaction, BeginTransaction, EndTransactionListen All
Comments (0)