RE: the file is locked
Posted in 1994
Isolation levels only apply when you're reading something. Setting isolation to dirty read will make no difference to how an INSERT behaves. An INSERT needs to acquire an exclusive lock on every data and index element it modifies. To do that it requires that no-one has a lock of any kind on either the data, the index or the table header. By 'element', I mean the individual row/ index entry if your table was created with LOCK MODE ROW; the whole page if it was LOCK MODE PAGE (the default). I suggest you do the following. 1) Find out which process/ program is holding the lock that your insert objects to and what they're doing at the time. See if you can re-work the offending prog so it doesn't lock as much; and see if you can get it to hold the lock for a much shorter time; quite likely by reducing the transaction duration. 2) Change the table on which the contention is occurring to LOCK MODE ROW if it isn't already. Both (1) and (2) could greatly reduce the probability of the contention occurring at all. In my experience excessive transaction duration is the most frequent cause of lock contention. 3) Put the statement SET LOCK MODE TO WAIT n (where n is a number of seconds) in the locked-out prog. This will give it a chance to hang on and try again if the lock contention is to be short-lived. 4) Write a graceful error handler that gives the user the option to re-try the insert if all else fails. akent@cix.compulink.co.uk (Andy Kent) ------------------------------------- 44 272 742815