Skip to main content

"revertTransactionToSavepoint"

JSON DB API action for undoing a transaction to a previously created savepoint

Abstract

FairCom JSON DB API's "revertTransactionToSavepoint" action reverts a transaction to a savepoint previously created by "createTransactionSavepoint". It undoes all transaction changes made after the savepoint and keeps the transaction open.

The "revertTransactionToSavepoint" action reverts a transaction to a savepoint previously created by "createTransactionSavepoint". It undoes all transaction changes made after the savepoint and keeps the transaction open to allow more actions to run inside the transaction.

Important

JSON DB API does not support "revertTransactionToSavepoint" when the transaction contains a call to "getRecordsUsingSQL" or "runSqlStatements"; instead, the JSON DB API returns an error.

The JSON DB API does support "rollbackTransaction" and "commitTransaction" when the transaction contains "getRecordsUsingSQL" or "runSqlStatements".

  • All transactions after the savepoint are permanently discarded, and changes up to the savepoint still need to be committed. This can undo changes to records, tables, indexes, etc.

  • This action cannot be undone.

  • This action does not close a transaction.

  • Additional commands can continue to be executed under transaction control.

  • To commit all changes up to the savepoint, call the "commitTransaction" command.

  • A transaction can only be closed by "commitTransaction" or "rollbackTransaction".

Examples

Request examples

Minimal request example

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

Response examples

Successful response example

{
  "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.