>>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
IF <i>no errors detected</i>
END TRANSACTION
ELSE
ROLLBACK
ENDIF