Setting Savepoints

You can identify important states within a transaction and return to them selectively by using savepoints to separate groups of related statements.

  1. Connect to the database:
    CONNECT DATABASE iqdemo 
  2. Start a read/write transaction:
    INSERT INTO FinancialCodes
    (Code, Type, Description) 
    VALUES ('e8', 'expense', 'Services')
  3. Set a savepoint:
    SAVEPOINT TUES9_45

    Naming your savepoint (as shown) is optional. You must follow the rules for object names described in Reference: Statements and Options.

  4. Start a read/write transaction:
    INSERT INTO FinancialCodes
    (Code, Type, Description) 
    VALUES ('r3', 'fees', 'Administration')
    COMMIT

    If this insert command were to fail, the transaction would roll back to Savepoint TUES9_45. The data inserted in Step #2 would not be lost.