Locks for DML Operations

Data manipulation language (DML) operations include insertions, deletions, updates, and queries. For all such operations, Sybase IQ permits one writer and multiple readers on any given table.

This rule has the following implications:

The first transaction to open a table in write mode gains access to the table. A second transaction that tries to open the table in write mode receives an error. Any additional attempts to write to the table in the current transaction will fail. The transaction can continue, but only with read operations or with writes to other tables.

Sybase IQ supports SHARE, WRITE, and EXCLUSIVE lock enqueuing, allowing you to lock a table for a specified period. You can WRITE lock multiple tables at one time.

To avoid future version errors from subsequent DML statements, reserve a WRITE lock on the table or set of tables that you plan to modify. See the LOCK TABLE statement in Reference: Statements and Options.

In the case of deadlocks, the last LOCK TABLE statement that became blocked is usually rolled back and an error returns to that transaction about the form of deadlock that occurred.

In certain cases, you must issue COMMIT or ROLLBACK statements. If SYNCHRONIZE JOIN INDEX fails due to table x has no data with which to join the other tables, all database tables that participate in the join indexes and join virtual tables remain locked in WRITE mode until you explicitly disconnect or issue a COMMIT or ROLLBACK statement. Explicit COMMIT or ROLLBACK is also required to release locks when DML statements fail for example, due to integrity constraints.

If a DML statement fails due to a referential integrity violation on the referenced table or an unavailable lock on other tables, Sybase IQ returns SQL Anywhere Error -210.