In transactions, you can explicitly lock a table with the lock table command.
To immediately lock the entire table, rather than waiting for lock promotion to take effect.
When the query or transactions uses multiple scans, and none of the scans locks a sufficient number of pages or rows to trigger lock promotion, but the total number of locks is very large.
When large tables, especially those using datarows locking, need to be accessed at transaction level 2 or 3, and lock promotion is likely to be blocked by other tasks. Using lock table can prevent running out of locks.
The table locks are released at the end of the transaction.
lock table allows you to specify a wait period. If the table lock cannot be granted within the wait period, an error message is printed, but the transaction is not rolled back.
See lock table in the Adaptive Server Reference Manual for an example of a stored procedure that uses lock time-outs, and checks for an error message. The procedure continues to execute if it was run by the System Administrator, and returns an error message to other users.