The LOCK TABLE statement either prevents concurrent application processes from changing a table or prevents concurrent application processes from using a table.
This statement can be embedded in an application program or issued interactively. It is an executable statement that can be dynamically prepared.
The privileges held by the authorization ID of the statement must include at least one of the following:
>>-LOCK TABLE--table-name--IN--+-SHARE MODE----------------+---><
+-EXCLUSIVE MODE ALLOW READ-+
'-EXCLUSIVE MODE------------'
A shared lock (*SHRNUP) is acquired for the application process in which the statement is executed. Other application processes may also acquire a shared lock (*SHRNUP) and prevent this application process from executing any but read-only operations.
An exclusive allow read lock (*EXCLRD) is acquired for the application process in which the statement is executed. Other application processes may not acquire a shared lock (*SHRNUP) and cannot prevent this application process from executing updates, deletes, and inserts on the table.
An exclusive lock (*EXCL) is acquired for the application process in which the statement is executed.
Locks obtained: Locking is used to prevent concurrent operations.
The lock is released:
You may also issue the Deallocate Object (DLCOBJ) command to unlock the table.
Conflicting locks already held by other application processes will cause your application to wait up to the default wait time of the job.
Obtain a lock on the DEPARTMENT table.
LOCK TABLE DEPARTMENT IN EXCLUSIVE MODE