Unlocking Tables

It’s there any way of unlocking a table after using LOCKTABLE on it but before finishing the process that called the LOCKTABLE? (before someone asks why… after doing the locktable process and obtaining the info from the locked tables there is still a long time consuming process to be done, but if the tables are locked users must wait for the process to end before continuing their works). Thnx a lot – Alfonso Pertierra apertierra@teleline.es Spain

Navision is very strong in transactions. When you start modifying/inserting/deleting something you start a transaction. The transaction persists until your Report or whatever you are doing is completed. If there is an error in the execution that you don’t take care of, you get an exception, and the transaction is rolled back. It puts a heavy load on your server if you update one field in 2 million records, but in the event of an error you are rolled back, and no harm is done. Just correct and run again. If you want to take control over the transaction handling, the simplest way is to put in a COMMIT statement. The transaction will end, and whatever is next in your code will be part of a following transaction. This will also free tables that are automatidally locked by the intrinsic transaction handling. Example: You code starts with inserting new records in a table. When creating the new records, the No. series table is locked, so it could be rolled backed in case of an error. Then you make calculations on the new records. If you insert a COMMIT after the new records are inserted, you free the No. series table so other users could insert orders, invoices etc. This table locking problem of native Navision should be done with in the SQL server version, which uses the more friendly record locking approach. Pelle

Short answer: COMMIT ------- With best regards from Switzerland Marcus Fabian

sigh just using COMMIT?? (I was hoping not having to use it, as we don’t want also writing data to the destination table after all processing with the read data is done sucessfully) Thnx a lot :wink: – Alfonso Pertierra apertierra@teleline.es Spain

I think you might have to rewrite the logic of the procedure. I understand that you do the following:


TableA.Get;
TableA.LockTable;
GetSomeStuff(TableA);
TableA.Modify

What about not locking the table while you GetSomeStuff ? Like:


TableA.Get;
GetSomeStuff(TableA);
TableA.LockTable;
TableA.Modify;
COMMIT;

------- With best regards from Switzerland Marcus Fabian

Have your tried CLEAR(YourTable); in order to unlock your table ? I never tried it but in theory this should work. tarek_demiati@ureach.com