Setting lock mode in informix to wait before executing query

In my vb application i have a query that updates one column in a table. But because of the fact that the property for this database lock mode is

SET LOCK MODE TO NOT WAIT

sometimes when running query with update I get errors like this:

SQL ERR: EIX000: (-144) ISAM error: key value locked
EIX000: (-245) Could not position within a file via an index. (informix.table1)

My question is , is it safe to execute:

1st SET LOCK MODE TO WAIT;

 2nd the update query;

 3rd SET LOCK MODE TO NOT WAIT;

Or you can point me to other solution if this is not safe

Upvotes: 1

Views: 1070

Answers (1)

Jonathan Leffler
Jonathan Leffler

Reputation: 755054

It is "safe" to do the three operations as suggested, but …

  • Your application may block for an indefinite time while the operation runs.
  • If you terminate the query somehow but don't reset the lock mode, other parts of your code may get hung on locks unexpectedly.

Consider whether a wait with timeout is appropriate.

Each thread, if there are threads, should have exclusive access to one connection for the duration of the three operations.

Upvotes: 2

Related Questions