Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BEGIN/END Transaction
Message
From
10/08/2003 15:56:59
 
 
To
10/08/2003 13:42:10
Shlomo Kupperman
Blumenfeld Development Group
Syosset, New York, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00818711
Message ID:
00818731
Views:
23
>Hi all,
>I have a process which spans over 3 databases (Job Cost, AP, GL). I have tables open in the DE from all 3 DB's. The process must keep the integrity of all the tables modified in all 3 DB's.
>My question is, do I need to issue 3 Begin Transaction commands (before each process of the appropriate DB) and 3 End Transaction / Rollback, or I need only one at the begining of the process and one at the end.
>I am using VFP 7.
>
>TIA,
>
>
>Shlomo

Hi Shlomo,

In VFP, transaction is scoped to a data session not to a data base. It doesn't matter whether tables belong to the same database or to different databases, they all going to be affected by transaction if they opened in the same data session. In your scenario, tables are opened in DE, so they belong to the same data session and they all going to affected by transaction.

Here is a little code:
CLOSE DATABASES all
CLEAR 

delete DATABASE dbtest1 DELETETABLES 
delete DATABASE dbtest2 DELETETABLES 
delete DATABASE dbtest3 DELETETABLES 

CREATE DATABASE dbtest1
CREATE TABLE dbtest1 (f1 I)
INSERT INTO dbtest1 VALUES (1)
INSERT INTO dbtest1 VALUES (11)
INSERT INTO dbtest1 VALUES (111)

CREATE DATABASE dbtest2
CREATE TABLE dbtest2 (f1 I)
INSERT INTO dbtest2 VALUES (2)
INSERT INTO dbtest2 VALUES (22)
INSERT INTO dbtest2 VALUES (222)

CREATE DATABASE dbtest3
CREATE TABLE dbtest3 (f1 I)
INSERT INTO dbtest3 VALUES (3)
INSERT INTO dbtest3 VALUES (33)
INSERT INTO dbtest3 VALUES (333)

PrintState()

?"BEGIN TRANSACTION"
BEGIN TRANSACTION 

?"Modify tables from different databases"
replace f1 WITH f1*10 ALL IN dbtest1
replace f1 WITH f1*10 ALL IN dbtest2
replace f1 WITH f1*10 ALL IN dbtest3

PrintState()

?"ROLLBACK TRANSACTION"
ROLLBACK 

PrintState()


FUNCTION PrintState()
	SELECT dbtest1
*	?ALIAS()
	LIST 

	SELECT dbtest2
*	?ALIAS()
	LIST 

	SELECT dbtest3
*	?ALIAS()
	LIST 
ENDFUNC 

return
Thanks,
Aleksey.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform