
The begin transaction command is used to mark the start of a unit of work called a transaction.
A transaction can be a whole procedure or any part of a procedure that enters or modifies data (a procedure that includes an enter a record, modify records, or delete records command). When processing reaches a begin transaction command, DataEase treats the statements that follow as part of the same transaction until it reaches a commit, rollback, or another begin transaction command. A procedure can contain any number of begin transaction commands.
Syntax
begin transaction
Usage
When a DQL Procedure is translated into SQL, DataEase inserts an implicit begin transaction command at the beginning of the procedure. If you insert an explicit begin transaction command outside a for loop or conditional statement, it is ignored when the procedure is translated into SQL. If you insert an explicit begin transaction command inside a for loop or conditional statement, it is interpreted as a savepoint when the procedure is translated into SQL.
The commit command is used to end a transaction and save all the modified data. Once a transaction is committed, it cannot be undone by a rollback command.
begin transaction
for DAILY RESERVATIONS with ( POSTED = NO) ;
enter a record in YEARLY RESERVATIONS
copy all from DAILY RESERVATIONS .
if sum of YEARLY RESERVATIONS AMOUNT > 80000
The procedure in Example 1 contains three operations that are treated as a single transaction. The first operation enters a record in the YEARLY RESERVATIONS table using the values in the DAILY RESERVATIONS table. The second operation modifies the POSTED field in the DAILY RESERVATIONS table to indicate that the record was posted to the YEARLY RESERVATIONS table. The third operation modifies the records in the RESERVATION AGENTS table whose yearly sales total is greater than $80,000.00. When processing reaches the commit command, the updates to the parent record and both child records are saved together. If any part of the transaction fails, the entire transaction is rolled back.
begin transaction
modify records in MEMBERS
ACCOUNT BALANCE := ACCOUNT BALANCE +
RESERVATIONS TOTALDUE .
modify records in RESERVATION AGENTS
RESERVATIONS TOTALDUE .
modify records in CLUB ROOMS
RESERVATIONS ROOMSREQUIRED .
if current SQLCODE not = 0 then
RESERVATION ID .
The procedure in Example 2 contains four modify operations that are treated as a single transaction. The first operation updates a record in the MEMBERS table using the value in the TOTAL DUE field in the RESERVATIONS table. The second operation updates a record in the RESERVATION AGENTS table using the value in the TOTAL DUE field in the RESERVATIONS table. The third operation updates a record in the CLUB ROOMS table using the value in the ROOMS REQUIRED field in the RESERVATIONS table. The fourth operation updates the current record by setting the POSTED field to YES.
When processing reaches the commit command, all four of the modifications are committed together. If any part of the transaction fails, the entire transaction (all four modifications) is rolled back. The current SQLCODE variable is set to zero if the commit is successful and to an SQL engine-specific error code if the commit fails. If DataEase is unable to commit all the modifications for a specific order, the order number is listed in the procedure output.
Product: DataEase for Windows 7.x. Written by George Washington 11/04/14 at 08:26:17
Product: DataEase 8 Reporter. Written by eduardo paez 02/05/14 at 14:40:11
Product: . Written by Marco Marchesi 15/02/16 at 14:50:46
Product: . Written by Grossi Gioacchino 18/11/19 at 14:33:44
Product: Dataease [{8}]FIVE. Written by Rainer 22/03/21 at 11:13:10
Product: Dataease [{8}]FIVE. Written by Rainer 08/06/21 at 14:12:40