Re: 4gl table locking
Posted in 1994
>I am a beginner at Informix and their 4gl. The version I have is 4.10. >The problem that I am trying to resolve is that using Informix's 4gl >and trying to lock a table in exclusive mode that is already locked >by another program. The second program that tries to lock the table >crashes out of the application back to UNIX. > >My question is there any standard way of having a program wait >gracefully >until the another program unlocks the table?. It seems that SET LOCK >MODE TO WAIt is only for record locking and not table locking. First of all, ask whether an exclusive table lock is really what you want. It is very rare to really need this. Row level locks and/ or share locks are virtually always adequate. Remember a share lock will stop anyone changing anything on that resource. Informix for the most part implements locking very well, I'd read Chapter in the "Guide to SQL Tutorial" and see what it can do for you. Next, what you need is a good error handler. Use WHENEVER ERROR CALL <error-function-name> to drop into it whenever there's an error. The error handler, which would be a function that you only ever have to write once for the whole site, checks the SQL and ISAM error codes to decide whether it's a lock error, and does something like give the user the option to re-try the action. I'm afraid you're on your own how the calling routine deals with this, you may end up with while loops round every database call if you take it to extremes. Thirdly and most often overlooked, keep your transactions VERY SHORT to prevent locks being held on to for too long and therefore denying other users access for an unreasonable period. akent@cix.compulink.co.uk (Andy Kent) ------------------------------------- +44 117 974 2815