Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Begin Transaction ....
Message
From
28/06/2002 07:35:19
 
 
To
27/06/2002 22:44:14
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00673158
Message ID:
00673207
Views:
16
Carmen,

1) You *must* use table buffering;
2) You *must* use TABLEUPDATE()s on each of your tables;

3) Also, depending on the actual logic needed, you may (should) use only 1 BEGIN TRANSACTION (*IF* all of the updates are an 'all-or-nothing' situation).

Finally when using transactions, keep in mind that ALL affected records are locked from all users until a END TRANSACTION/ROLLBACK is issued, so the prescribed way to code them is, highly counter-intuitively, along the lines of:
SELECT Table1
APPEND/REPLACE
SELECT Table2
APPEND/REPLACE
SELECT Table3
APPEND/REPLACE

BEGIN TRANSACTION
TABLEUPDATE(....Table1)
TABLEUPDATE(....Table2)
TABLEUPDATE(....Table3)
END TRANSACTION
good luck


>hi,
>
>I have a Visual Foxpro Ver7 program which opens two databases: stock and
>account.
>When an invoice is issued, it will update records to tables in both
>databases using the Begin..End Transaction feature (without Table Buffering). The problem is, it is unstable and sometimes there are records not being appended to the account tables or the index not being synchronised. My suspicion is because I use the
>transaction processing against two different databases incorrectly. Here is a rough
>sample of my updates:
>
>BEGIN TRANSACTION
>Append/Replace tables in Stock DB
>..
>Append/Replace tables in Account DB
>..
>Append/Replace tables in Stock DB
>..
>
>if no error detected
> END TRANSACTION
>else
> ROLLBACK
>endif
>
>I can't seem to find examples in documentation that use more than one
>database. Does anyone know how it is done?? Do I need to nest transactions as such:
>
>SET DATABASES TO STOCK
>BEGIN TRANSACTION
>Append/Replace tables in Stock DB
>..
>SET DATABASES TO ACCOUNT
>BEGIN TRANSACTION
>APPEND/REPLACE TABLES IN STOCK DB
>END TRANSACTION
>..
>..
>Append/Replace tables in Stock DB
>..
>..
>SET DATABASES TO ACCOUNT
>BEGIN TRANSACTION
>APPEND/REPLACE TABLES IN Account DB
>END TRANSACTION
>..
>..
>Append/Replace tables in Stock DB
>..
>IF no error detected
> END TRANSACTION
>ELSE
> ROLLBACK
>ENDIF
>
>Thanks
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform