Question:
Is it possible to do row level locking when working with an Informix
server?
Answer:
All settings and options for row level locking are done
at the table and database level.
The client application does not require any modifications
or specific Informix server support to benefit from
Informix Online row level locking.
Please see your Informix documentation for specific server and
table settings.
Example Informix table create (please see your Informix
documentation for specific information):
CREATE TABLE ROWLOCKTEST
(
FLD1 CHAR(5),
FLD2 FLOAT
)
LOCK MODE ROW
LOCK MODE PAGE is the default if not specified.
ALTER TABLE can be used to change the LOCK MODE for a table.
Example:
1)Start a transaction from the Informix client (TDatabase.starttransaction)
2)Modify a row and post (do not commit yet (TDatabase.commit))
3)From another client or connection attempt a change to the updated,
uncommitted row. The second client should time out.
4)All rows not currently involved in a transaction can be modified.
If the Informix table in the above example had been created or altered with
LOCK MODE PAGE then rows adjacent (within the same locked page) to the row
or rows currently part of a pending transaction will also be locked.