Ordinarily, when you are developing applications in C/SIDE, you do not need to take into consideration transactions and table locking. There are, however, some situations in which you must lock a table explicitly. To do this, use the LOCKTABLE function.
For example, in the beginning of a function, you inspect data in a table and then use this data to perform various checks and calculations. Finally, you want to insert a record based on the result of these calculations. To ensure that your calculations make sense, you must be certain that the values you retrieved at the beginning of the transaction are consistent with the data that is in the table now. You cannot allow other users to update the table while your function is performing its calculations.
You can use the LOCKTABLE function to lock the table at the start of your function.
LOCKTABLE has the following syntax.
Record.LOCKTABLE([Wait] [, VersionCheck])
For more information about concurrency in Microsoft Dynamics NAV, see the following topics: