Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
More about table updates
Message
 
To
20/07/2001 17:22:46
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00533368
Message ID:
00533395
Views:
20
> 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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform