Re: Cursors
Posted in 1997
Deepak Pant <Deepak.Pant@blr.sni.de> wrote: :Hello, : :I have a query regarding the informix cursors. The usual behaviour :on the opening of the cursor is that a number of records which match :the where clause in the open cursor statement are fetched. A fetch :from the cursor fetches the records from the local cache and not :from the server. In my application this is causing a problem since :other informix sessions may be updating the table as well and hence :the values which are provided by the cursor may be invalid. : :Now is it possible that whenever I issue a fetch cursor the records :are fetched from the server/database itself and not the cursor which :probably has gone stale. This does depend on the development tool you are using. Assuming it's Informix 4GL or NewEra: Sadly Informix have no direct support for "key set cursors" which would have solved this problem. You can however easily implement them yourself. Simply create the cursor to select the primary key of the table (or tables) you want to read. When you need the actual data use another cursor to select a row at a time using the primary key from the first cursor. This will guarantee that the data isn't stale (or at least not as stale as using one cursor). We often use this approach within the same application to let a user scroll back and forth in a cursor doing updates as they go. In this way they allways see the updated data, not the prior versions that are in the cursor even though the user have done the updates themselves. This does of course require a cursor with hold if you are using transactions to avoide the scroll cursor beeing closed by the commits after the updates. Nils.Myklebust@idg.no NM Data AS, P.O.Box 9090 Gronland, N-0133 Oslo, Norway My opinions are those of my company The Informix FAQ is at http://www.iiug.org