Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Locking Tables
Message
De
20/06/2000 03:23:43
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00382022
Message ID:
00382081
Vues:
27
>>Hi all,
>>
>>Is there a way i can lock all tables for a single procedure without having to lock each table individually ?
>
>Set Exclusive On?

Another approach which doesn't quite do what is requested would be to wrap the entire set of updates in a transaction. A transaction is an all or nothing group of changes to the affected tables - it will only work if all changes in the transaction are successful. Data changes are held awaiting completion or termination of the transaction - other users will be blocked from making alterations to data involved in the transaction until you terminate the transaction by committing the data with END TRANSACTION, or back out the whole set of changes using ROLLBACK. You would trap any errors within your transaction, andif the error invaliates the transaction, you can issue a ROLLBACK which restoreswhatever changes were made inside the transaction.

VFP automatically acquires and holds required locks on all affected tables for the duration of the transaction. This makes it desirable to make the transaction happen as promptly as possible. Often a process will collect all the changes needed for a transaction to some temporary tables, and then start the transaction, applying updates based on the data held in the temporary tables rather than beginning a transaction and waiting on some user interactions. It's not good when someone starts a transaction, forgets to finish it and goes out to lunch for an hour, preventing everyone else from working...
BEGIN TRANSACTION
*
*  Do all changes to all tables
*
IF <i>no errors detected</i>
   END TRANSACTION
ELSE
   ROLLBACK
ENDIF
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform