Re: Help! - NewEra supertable locking handling
Posted in 1997
On 29 Jan 1997, Peter Neville wrote: > I am having difficulties with pessimistic locking of a supertable in Newera > v2.11 > > My main query is how do I stop the informix error message 'error number > -50015 ixSuperTable::applyRowLock()-250)' when a row is already locked by > another user. > > I am have turned off auto-commit and handled the error in the > uponafterrowlock handler. My code identifies and reports the > error(rowlock), but I just cannot stop the Informix error message which > appears before my message. Although everything works okay, the informix > message is not very friendly, I just want a simple 'in use, try again > later' message. > > Should I use the WHENEVER SQLERROR CALL function ? (tried with no success) > Or write my own applyRowLock() function ? (I think this may be difficult) > There are two solutions to this problem. Go fetch the record If the record is already locked by another user, You can do two things. 1) Give an error message and tell the user to try back later. 2) Wait untill the lock is released. 1) First Case: This is to Handle the error Message. Show an error message that the user can understand. A message which will not upset the user. COde like this in the Window where you are getting this message . But it is a great Idea to put this code in your Application template so that it will work for all your Windows. ---begin prebody HANDLER ixapp::OURerrorhandler(errnum INTEGER, severity SMALLINT, errData1, errData2, errData3 CHAR(*)) RETURNING VOID variable nStatus smallint VARIABLE titlestr CHAR(*) LET titlestr = "We Have an Error" || errnum, errData1 case errnum when -50015 IF errData1 IS NOT NULL THEN CASE errData1 WHEN -250 let nStatus = messagebox(new ixstring(titlestr), new ixstring("You are attempting to to look at a record already locked by another usr. Please wait and try again later" )) OTHERWISE CALL showRTerror(errnum,severity,errdata1,errdata2,errdata3) END CASE END IF -- You can handle any number of error messages. otherwise CALL showRTerror(errnum,severity,errdata1,errdata2,errdata3) end case END HANDLER --- end prebody ---- begin start HANDLE ixapp::getapp().rtError with ixapp::OURerrorhandler ----- end start 2) The second Solution After the Connect statement SQLstmt.execdirect("SET LOCK MODE TO WAIT 15") You can remove 15 and just say "SET LOCK MODE TO WAIT" then the system will wait forever untill the lock is released. But sometimes you don't want to wait forever then replace 15 with whatever time you want. In our applications we use both. We will wait for 30 seconds if the record is still locked then give the error message Regards Rajeev Nimmagadda SRK rajeevn@jcdcrs4.jobcorps.org # (512)393-7204 ################################################################