Re: Tracking Deleted Records Within SCROLL'd CURSOR
Posted in 1993
In article <1993Apr16.195013.15634@venice.sedd.trw.com> ries@hqrim.sedd.trw.com (Marc Ries) writes: > Situation (bear with my long-winded explanation): > [long-winded explanation deleted...] > So (finally), for the question: > > What's the most efficient way to keep the user from seeing "stale" > FETCH data. Is there any simple (or simpler way) than keeping some > hideous secondary array around to track what records have been deleted? There are a couple ways of doing this. In our 4gl training class we address this problem of stale data. We solve the problem by using 2 cursors. The first cursor is a SCROLL cursor that only selects the primary key when a QUERY is done (a construct stmt). The second cursor selects 'fresh' information from the database using the index from the first cursor. That is the following example. The other way to do this is create your own array and manipulate the array manually. Hope this helps... Good Luck, ________________________________________________________ ________| Mike Lee | There's a pizza place that sells |_______ \\ | Consultant/Trainer | only slices. You can see a guy in | / \\ | Informix Software | back tossing triangles. -S.Wright | / / |________________________________________________________| \\ /__________) (_________\\ Paraphrased: define gl_table1 record like table1.* let select_stmt2 = "select * from table1 where prim_key = ?" prepare p2_stmt2 from select_stmt2 construct... on table1.* let select_stmt1 = "select prim_key from table1 where ", wh_clause clipped prepare p1_stmt1 from select_stmt1 declare c1_stmt1 scroll cursor with hold for p1_stmt1 open c1_stmt1 declare c2_stmt2 cursor for p2_stmt2 #get the first primary key record fetch first c1_stmt1 into gl_table1.prim_key #open the second cursor using the just fetch'd primary key open c2_stmt2 using gl_table1.prim_key # fetch the fresh information into the program record fetch c2_stmt2 into gl_table1.* close c2_stmt2 --------------------------------------------------------------------------- for the NEXT and PREV options just create a function passing a 1 or -1 function(direction) define direction fetch relative direction c1_stmt1 into gl_table1.prim_key if successful... OPEN and FETCH the c2_stmt2 cursor....