Choosing a RELEASE option
The RELEASE bind option controls when an application releases locks that it acquires on objects such as partitions, tables, or table spaces that it accesses. It applies only to partition, table, and table space locks.
About this task
An application program acquires
table, partition, or table space locks only when it accesses the specific
objects. In most cases, the least restrictive lock mode that is required
to process each SQL statement is used. However, a statement sometimes
reuses a more restrictive lock than required, if a suitable lock remains
from a previous statement that accessed the same objects.
- When you use RELEASE(DEALLOCATE) and KEEPDYNAMIC(YES), and your subsystem is installed with the CACHEDYN subsystem parameter set to YES, the RELEASE(DEALLOCATE) option is honored for dynamic SELECT, INSERT, UPDATE, and DELETE statements. For more information, see CACHE DYNAMIC SQL field (CACHEDYN subsystem parameter) and KEEPDYNAMIC bind option.
- When you use RELEASE(DEALLOCATE), prepared INSERT, UPDATE, DELETE, and MERGE dynamic statements that reference declared temporary tables are kept past commit points unless the table was defined with the ON COMMIT DROP TABLE option.
The RELEASE option does not apply to page, row, LOB, or XML locks.
Procedure
To select a RELEASE bind option that is appropriate for the characteristics of a particular application, use any of the following approaches:
Example
Consider an application that selects employee names and telephone numbers from a table. Assume that employees can update their own telephone numbers, and they can run several searches in succession. The application is bound with the RELEASE(DEALLOCATE) bind option because most uses of this application do not update and do not commit. For those uses, little difference exists between RELEASE(COMMIT) and RELEASE(DEALLOCATE).
However, administrators might update several
phone numbers in one session with the application, and the application
commits after each update. In that case, RELEASE(COMMIT) releases
a lock that Db2 must
acquire again immediately. RELEASE(DEALLOCATE) holds the lock until
the application ends, avoiding the processing that is required to
release and acquire the lock several times.

