Re: Scroll Cursor for Update
Posted in 1997
steve53@earthlink.net wrote: > > Hi, > > I'm in the process of rewriting the database access library for one of > our applications. The original database was proprietary and the new > database will be Informix-SE. Currently we have v5.x. V7.x is on > order. > > It appears that v5's dynamic ESQL C does not allow me to open a SCROLL > CURSOR against a SELECT statment defined as FOR UPDATE. > > Does v7 relax this restriction? No. By definition a SCROLL cursor actually creates a temp table with the selected values and allows you to scroll around in the temp table since the FOR UPDATE clause allows one to update the row CURRENT to the CURSOR declared FOR UPDATE this makes no sense for a SCROLL CURSOR since the updated row will only be a temporary copy of the original row and the relationship between the copy and the original has been lost. To effect a similar result select the ROWID along with the other information that you want and update the original row by ROWID. For concurrency control you could open a second FOR UPDATE cursor on the single row the user is updating on screen by ROWID to lock it until the user commits. If you do not want to lock users out of rows for so long you could refetch the data with a FOR UPDATE CURSOR just before updating and compare values to the original ones FETCHED from the SCROLL CURSOR and abort the update if the row has been updated by another user while the current user was browsing. Art S. Kagel