D Eloquence Library

The COMMIT Function

The COMMIT function commits (sub-) transaction . The syntax is as follows:

   idb_commit(mode,status)

   int mode;
   int status[10]
The parameters are:

mode
Must be 1 or 2, see below.
status
A pointer to an array of a least 10 elements used to indicate the success or failure of the function call (see below).

IDBCOMMIT Modes

Mode 1: Commit current (sub-)transaction

idb_commit commits the current transaction. If this is the toplevel transaction, modifications are made permanent to the database. A commit on a subtransaction does only cause all modifications to become part of the parent transaction.

Mode 2: Commit top level transaction

idb_commit can be directed to commit the toplevel transaction and any currently active subtransaction.

Description

Database modifications made in a transaction are not saved in the database until the enclosing is commited. When the commit function succeeds it is guaranteed that all modifications succeeded. In case the commit fails the database it not modified at all.

As you probably have noticed, idb_commit does not take a database argument. Transactions are global for all databases even if they are executed on different servers.

Return value

Returns 0 if successful, or error number if an error was encountered.

Status codes

If idb_commit was successfully executed, the status array will contain the following values:

Status codes
ElementMeaning
0S_OK
10
20
30
40
50
60
70
80
90

Example

   if(idb_begin(NULL, 1,status))
      error_handler();
   ...
   if(idb_commit(1,status))
      error_handler();
This will commit any modifications made in the transaction and finish the transaction.


Eloquence Database Manual - 19 DEC 2002