XAP

Transactions Control Language (TCL) Syntax

Transactions group a set of tasks into a single execution unit. Each transaction begins with a specific task and ends when all the tasks in the group are successfully completed. If any of the tasks fail, the transaction fails. Therefore, a transaction has only two results: success or failure. You can explore more about transactions

Transaction Control Language (TCL Syntax)

BEGIN/START and END/COMMIT are available to define the beginning and end of a Logical Unit of Work as a transaction. ROLLBACK can also be used to undo a transaction.

Example 1:

Syntax Explanation

BEGIN (or START);

Opens a Transaction

INSERT …xxx…;

 

INSERT …yyy…;

 

SELECT …xxx…;

OK

SELECT …yyy…;

OK

END (or COMMIT);

End transaction with commit

Example 2:

Syntax Explanation

BEGIN (or START);

Begin transaction

INSERT …xxx…;

 

SELECT …xxx…;

OK

ROLLBACK;

Rollbacks a transaction in case of any error occurs.

SELECT …xxx…;

Not found

INSERT …yyy…;

 

SELECT …yyy…;

OK

COMMIT;

End transaction with commit

SELECT …yyy…;

OK

END (or COMMIT);

End transaction with commit (nothing to commit)