Skip to main content

"commitTransaction"

Abstract

commitTransaction commits a transaction and, when successful, ensures all actions attached to the transaction have been completed successfully and durably.

The "commitTransaction" action closes a transaction created by "createTransaction" and commits all changes made by actions attached to the transaction by ensuring all changes become durable and visible to other transactions.

Optionally include the "transactionSavepointId" property to commit the transaction up to a savepoint.

Things to know

  • "commitTransaction" uses the "transactionId" property returned from the "createTransaction" action to identify the transaction.

  • Once a transaction is committed or rolled back, you can no longer use the transaction’s "transactionId".

  • An error is returned when the "transactionId" property does not represent a transaction assigned to the current session.

  • If any part of a transaction cannot be committed, the "commitTransaction" action fails, and all changes in the transaction are rolled back as if they had never occurred.

Request examples

Minimal request example

{
  "api": "db",
  "authToken": "replaceWithAuthtokenFromCreateSession",
  "action": "commitTransaction",
  "params": {
    "transactionId": "replaceWithTransactionIdFromCreateTransaction"
  }
}
{
  "api": "db",
  "apiVersion": "1.0",
  "requestId": "2",
  "authToken": "replaceWithAuthtokenFromCreateSession",
  "action": "commitTransaction",
  "params":
  {
    "transactionId": "replaceWithTransactionIdFromCreateTransaction",
    "transactionSavepointId": "replaceWithTransactionSavepointIdFromCreateTransactionSavePoint"
  },
  "responseOptions": {},
  "debug": "max"
}

Response examples

{
  "authToken": "authtoken",
  "errorCode": 0,
  "errorMessage": ""
}

"params"

The "params" property is an object that contains an action's parameters. Each action defines its own required and optional properties.

Property summary

Table 1. "params" property summaries

Property

Description

Default

Type

Limits (inclusive)

"transactionId"

contains a server-generated ID that represents a transaction

""

string

Minimum length: 0
Maximum length: 255

"transactionSavepointId"

contains a server-generated ID that represents a savepoint

""

string

Minimum length: 0
Maximum length: 255


The "transactionId" is an option string that the server generates in order to return during a "createTransaction" action. The generated ID represents a transaction. It defaults to an empty string.

Things to know:
  • When a client wants an action to be under control of a transaction, it must include the "transactionId" in the action.

  • A "transactionId" is valid and can be applied to many actions until it is either committed using "commitTransaction" or rolled back using the "rollbackTransaction".

  • A zero-length string mean the "transactionId" is invalid.

  • Do not assume that "transactionId" is a number embedded in a string.

The "transactionSavepointId" is an optional string that the server generates in order to return during a "createTransactionSavepoint" action. The generated ID represents a savepoint. It defaults to an empty string.

Things to know:
  • A transaction savepoint represents the current point in the transaction process.

  • A client can roll back a transaction to any savepoint by calling the "rollbackTransaction" action with the desired "transactionSavepointId" property.

  • A client can commit a transaction to any savepoint by calling the "commitTransaction" action with the desired "transactionSavepointId" property.

  • A zero-length string means the "transactionSavepointId" is invalid.

  • Do not assume that the "transactionSavepointId" is a number embedded in a string.