COMMIT WORK
Commits
the current transaction.
SYNTAX
DESCRIPTION
The COMMIT
WORK command commits the current transaction. DBMaker automatically starts
a new transaction after you execute the COMMIT WORK command. Any user
with CONNECT or higher security privileges can execute the COMMIT WORK
command.
A transaction
is traditionally defined as a logical unit of work, or, one or more operations
on a database that must be completed together to leave the database in
a consistent state. Transactions are self-contained and must either complete
successfully and change the data, or fail and leave the data unchanged.
For example,
suppose you store two different kinds of information in your database:
records of shipments sent to customers and records of items currently
in stock (both including quantity of items). When an item is shipped to
a customer, the item and the quantity shipped is added to the shipment
list. The quantity shipped must also be subtracted from the items currently
in stock. If both of these operations are not completed together as a
logical unit of work, the database will be in an inconsistent state. Either
the quantity of items in stock will be too high (items shipped, but not
subtracted from items in stock) or too low (items subtracted from items
in stock, but not shipped). Both of these operations together make up
a single transaction, and both must complete successfully or both must
fail.
If a transaction
completes successfully and changes the data, we say it has been committed.
If a transaction fails and leaves the data unchanged, we say it has been
rolled back.
When you
execute the COMMIT WORK command, DBMaker will write all changes made by
commands in your current transaction to the database. Note that the COMMIT
WORK command only writes changes for your current transaction, not all
active transactions in the database. The COMMIT WORK command is not required
if your connection to a database is running in AUTOCOMMIT mode.
AUTOCOMMIT
mode controls when DBMaker will commit a transaction. When AUTOCOMMIT
mode is on, each command is treated as a separate transaction. Pressing
the enter key to execute a command automatically commits the command if
it completes successfully, or rolls it back if an error occurs during
execution. When AUTOCOMMIT mode is off, all commands between successive
COMMIT WORK commands form a single transaction. Executing the COMMIT WORK
command commits any changes made in the transaction, and executing the
ROLLBACK WORK command rolls back all changes.
In the event
of a database crash, DBMaker will automatically roll back any transactions
that have not been committed. If you want the changes made in the rolled
back transactions reflected in your database, you must redo all commands
in these transactions when the database is restarted.
EXAMPLE
The following
example commits the changes made by all commands executed between the
first and second COMMIT WORK commands. The database is not running in
AUTOCOMMIT mode (AUTOCOMMIT is off).
COMMIT WORK
...
SQL Command
SQL Command
...
COMMIT WORK
|
RELATED COMMANDS
<
CLOSE LINK | Contents
| CONNECT >
|