Transactions Control (TCL) Syntax

Transaction Control (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:

BEGIN (or START);

Begin transaction

INSERT …xxx…;

 

INSERT …yyy…;

 

SELECT …xxx…;

OK

SELECT …yyy…;

OK

END (or COMMIT);

End transaction with commit

Example 2:

BEGIN (or START);

Begin transaction

INSERT …xxx…;

 

SELECT …xxx…;

OK

ROLLBACK;

End transaction with rollback

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)