AppendTransaction

AppendTransaction allows transactions to be directly inputted into a backup database.
unsigned __int64 AppendTransaction (
	unsigned int logNumber,
	__int64 position,
	unsigned int transactionID,
	__int64 length,
	const void* buffer
);

Parameters

logNumbera value between 0-65,535 that tells the system which cyclical log file this tranaction should be appended to.
positionto enable cross checking that slave log is insync with master.
transactionIDthe Transaction ID for the appending transaction. This has internal use and should not be changed.
lengththe length on the transaction buffer.
buffera buffer containing a correctly formatted buffer.

Return Values

If the method succeeds, the return value is zero else see error codes for more details.

Remarks

Example Use
  • C++
#include "ODBPP.h"

int wmain(int argc, wchar_t* argv[])
{
   unsigned __int64 error;
   const char16_t *message;
   unsigned int logFile, transactionID;
   __int64 length = 0, size, position;
   BYTE *buffer = NULL;
   CODBPP database, backup;
   //production database is read only
   if((error = database.OpenDatabase(u"YourDatabase")) == NO_ERROR){
      if((error = backup.OpenDatabase(u"YourBackupDatabase")) == NO_ERROR){
         //lock backup database from other transactions
         if((error = backup.BeginTransaction(CODBPP::EXCLUSIVE)) == NO_ERROR{
            //get last transaction from backup log file
            if ((error = backup.WaitNextCommit(&logFile, &position, &transactionID, &size)) == NO_ERROR) {
               while (error == NO_ERROR) {
                  //gets next after the the inputted commit
                  if ((error = database.WaitNextCommit(&logFile, &position, &transactionID, &size)) == NO_ERROR) {
                     if (length < size || (size << 4) < length) {
                        if(buffer != NULL) delete[] buffer;
                        buffer = new BYTE[(length = (size + 0x3f)&~0x3f)];
                     }
                     size = length;//resets length to maximum size
                     //reads the next commit
                     if ((error = database.WaitNextCommit(&logFile, &position, &transactionID, &size, buffer)) == NO_ERROR)
                        //append the previous transaction to the backup database
                        error = backup.AppendTransaction(logFile, position, transactionID, size, buffer);
                  }
                  else if (ERROR_MASK(error) == WAIT_TIMEOUT) error = NO_ERROR;
               }
            }
         }
         backup.EndTransaction();
      }
      backup.CloseDatabase();
   }
   if(error && database.GetErrorMessage(&message) == NO_ERROR)
      MessageBox(message);
   database.CloseDatabase();
   return NO_ERROR;
}

Since

Version 4.5

Updated

Version 4.5.1

Also See

WaitNextCommit
Listen All
Comments (0)
Characters left: 2500
 
Ekky Software Homepage T-Accounts Online ObjectDatabase++ TScript Ekky Software Homepage T-Accounts Onlinee ObjectDatabase++ TScript