Using select for update

Adaptive Server versions 15.7 and later support select for update to exclusively lock rows in datarows-locked tables for subsequent updates within the same transaction, and for updatable cursors. This prevents other concurrent tasks from updating these rows and from blocking the subsequent update. select for update is supported at isolation levels 1, 2, and 3.

In versions earlier than 15.7, a select statement with a for update clause can be issued only within a declare cursor statement.

In Adaptive Server versions 15.7 and later, select for update can be issued as a language statement outside of a cursor context. With both language statements and cursors, you must execute select for update within a begin transaction command or in chained mode.

If you run select for update within a cursor context, the cursor open and fetch statements must be within the context of a transaction. Otherwise, Adaptive Server reverts to pre-15.7 functionality.

Syntax

select <col-list> from … where …
	[for update[ of col-list ]

NoteTo obtain version 15.7 functionality, and exclusive locks, you must set the select for update configuration parameter to 1, and include the for update clause. If the configuration parameter is not set, Adaptive Server reverts to pre-15.7 functionality.