Re: Refreshing a Cursor
Posted in 1996
Mr H. Gerlach (gerlachh@pirmasens-amedd.army.mil) wrote:
: Hello 4gl folks
: I have a question about refreshing a cursor.
: The problem is in a 4GL application with Add,Update,Previous,Next Capability
: that after you updated a row, hit next and then previous again, that you
: have the old values still displayed on the screen. I think this problem
: is caused by the cursor thats opened. Is there a simple way to somehow
: "refresh" the cursor without running another select??
: Your help would really be appreciated
: Thanks in advance
It sounds like you're using a scroll cursor and are running into the stale
data problem. When you define
a scroll cursor, Informix creates a temp table and stores all the columns
from all the rows that you specified into it. So, when you do a Next/Prev,
it uses the temp table to display the data. When you do an update or delete,
it modifies the data in the actual table not in the temp table created by
the scroll cursor.
The way to get around this is to only include the columns in the table that
that make up the primary key (or some unique index) and use those in your
scroll cursor. When you do a Next/Prev, use the primary key to fetch all
the other columns from the table. Example:
declare sel_curs scroll cursor for
select col1, col2 # col1, col2 make up the primary
from table # key in the table
where ...
open sel_curs
When the user does a Next/Prev:
fetch next sel_curs into p_col1, p_col2
or fetch prev sel_curs into p_col1, p_col2
select *
into p_table
from table
where col1 = p_col1 and col2 = p_col2
--
Stefanie Vario
svario@zenacomp.com
ZenaComp Incorporated
http://www.zenacomp.com/~zenacomp