Another VFP 9 Cool Feature: MAKETRANSACTABLE()

If you're like me, you may have older Visual FoxPro applications that were upgraded from earlier versions and still use free tables. And why not? Databases certainly offer some benefits but they can be "clunky" to move around.
 
One of the reasons many developers switched to using databases and the DBC files were to support transactions : - that is the ability to start a transaction, update a bunch of files and then if one thing didn't work right, roll it all back to the original source.
 
Well now,  in Visual FoxPro 9 (Europa) , FREE Tables can be made transactable as well with the new MAKETRANSACTABLE() function.
 
Consider the following:
 
USE CUSTOMERS
MAKETRANSACTABLE( "CUSTOMERS")
BEGIN TRANSACTION
 
DELETE ALL
IF MESSAGEBOX("Did you really want to delete all your customers",4) <> 6
    ROLLBACK
ENDIF
END TRANSACTION
 
Note: that each table must be called MAKETRANSACTABLE in order to work. This means a few extra calls when your table is open.
 
When you close the table, the MAKETRANSACTABLE setting is removed.
 
One of the big challenges with older applications is ensuring that everything is always updated properly. With this great new feature, you can use Transactions with your free tables, ensuring that if something goes wrong, everything can be updated properly. Awesome feature.

Comments

Randy Jean said…
This could be a lifesaver for some work I'm doing with a new client that has all free tables and wants to implement buffering and transactions. Luckily, they've already deployed under VFP9.

Popular Posts