You are viewing the documentation for a prerelease version.

SAVEPOINT

    +
    The SAVEPOINT statement enables you to set a savepoint within a transaction.

    Purpose

    The SAVEPOINT statement enables you to set a savepoint within an ACID transaction. Refer to Transactions for further information.

    This statement may only be used within a transaction.

    If you are using the Query Workbench or the Query REST API, you must set the txid query parameter to specify the transaction ID.

    If you are using the cbq shell, you don’t need to specify the transaction ID. Once you have started a transaction, all statements within the cbq shell session are assumed to be part of the same transaction until you rollback or commit the transaction.

    Syntax

    savepoint ::= SAVEPOINT savepointname
    'SAVEPOINT' savepointname
    savepointname

    An identifier specifying a name for the savepoint.

    If a savepoint with the same name already exists, the existing savepoint is replaced.

    Examples

    Example 1. Set a savepoint — cbq shell
    Request
    cbq> SAVEPOINT s1;
    Example 2. Set a savepoint — REST API
    CURL request
    $ curl http://localhost:8093/query/service \
    -u Administrator:password \
    -H 'Content-Type: application/json' \
    -d '{
      "statement": "SAVEPOINT s1;",
      "pretty": true,
      "txid": "d81d9b4a-b758-4f98-b007-87ba262d3a51" (1)
    }'
    1 The transaction ID generated when the transaction began.