Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
More about table updates
Message
 
À
20/07/2001 17:22:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00533368
Message ID:
00533395
Vues:
18
> Now the problem is, when you run into this in
> the middle of, let's say processing on many
> tables, reverting would leave you with a
> partially processed order for example,..
> This may lead to incorrect inventory or
> incorrect total sales when calculating commission
> for a salesman..
Take a look at BEGIN TRANSACTION, END TRANSACTION and ROLLBACK commands. Transaction is a mechanism built-in into the database to handle this type of scenario that you describe.

This is the basic structure of a transaction with two tables. You can easily extend it to handle more tables:
begin transaction

lUpdateOk = TableUpdate( 2, .F., 'OneView' )
if lUpdateOk
   lUpdateOk = TableUpdate( 2, .F., 'AnotherView' )
endif

if lUpdateOk 
    * if all tables were updated successfully
    * then commit changes to database.
    end transaction
else
    * if any of the tables could not be updated
    * revert all table updates.
    rollback 
endif
Hector Correa
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform