Simplicty and flexibility!


Support::

Begin Transaction


Parameters


Returns/Result


Examples


Reference

begin transaction

image\Dql_0025.gifbegin transaction

Type

Procedural Command

Purpose

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.

Example 1

for RESERVATION AGENTS ;

begin transaction

for DAILY RESERVATIONS with ( POSTED = NO) ;

enter a record in YEARLY RESERVATIONS

copy all from DAILY RESERVATIONS .

modify records

POSTED = YES .

end

if sum of YEARLY RESERVATIONS AMOUNT > 80000

then

modify records

CHRISTMAS BONUS := YES .

end

commit .

end

 

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.

Example 2

for RESERVATIONS ;

begin transaction

modify records in MEMBERS

ACCOUNT BALANCE := ACCOUNT BALANCE +

RESERVATIONS TOTALDUE .

modify records in RESERVATION AGENTS

DAILY TOTAL := DAILYTOTAL +

RESERVATIONS TOTALDUE .

modify records in CLUB ROOMS

VACANCIES := VACANCIES -

RESERVATIONS ROOMSREQUIRED .

modify records

POSTED:= YES .

commit .

if current SQLCODE not = 0 then

list records

RESERVATION ID .

end

end

 

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.

See Also


On the forum about Begin Transaction

[@EOF@]...

Product: . Written by alembagheri tahmas 07/12/13 at 13:37:32

Hi there,I am trying to use an external MySQL DB in dataease. I have successfully create the ODBC link and added the DB to dataease. I can also access the DB from dataease. Now, just for testing purposes, I am trying to create a simple report b...

Product: DataEase for Windows 7.x. Written by George Washington 11/04/14 at 08:26:17

no se pude exportar ahora archivos a pdf, ni a excel o otros cosa mala. en verdad creo que hace faltaen las versiones anteriores me funcionaba mas o menos bien. le hace falta a los aplicativos que se desarrollan en Dataeasegr...

Product: DataEase 8 Reporter. Written by eduardo paez 02/05/14 at 14:40:11

Thanks. Anyway I'm trying to use this fuction but it seems to me that it doesn't work on 8.2. I tried also in a DQL.There's something wrong?<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA9IAAAJ3CAYAAAB4NWk3AAAAAXNSR0IArs4...

Product: . Written by Marco Marchesi 15/02/16 at 14:50:46

[@EOF@]...

Product: Dataease [{8}]FIVE. Written by Chamil Rajindra 21/02/19 at 10:17:46

Thanks for the very good explanation!AS...

Product: . Written by afonso santos 28/10/19 at 00:50:14

I am pleased to see that the migration from Dos 4.53 is then sa 5.5 works. A really useful thing would be a compiler of SQL languages. Will you get there?Original Text:Mi compiaccio a vedere che la migrazione da Dos 4.53 è poi sa 5.5 funzio...

Product: . Written by Grossi Gioacchino 18/11/19 at 14:33:44

How can i delete a Style sheet?...

Product: Dataease [{8}]FIVE. Written by Rainer 22/03/21 at 11:13:10

I run W7 and since a few days&nbsp;Dataease 8.5 is not starting any more, do you have an idea? i installed it again but that did not help....

Product: Dataease [{8}]FIVE. Written by Rainer 08/06/21 at 14:12:40

[@EOF@]...

Product: . Written by Hiralal Rampul 01/12/21 at 17:47:10

On the blog about Begin Transaction


dg3_HelpView