Re: ESQL/C problem
Posted in 1997
Ian Goddard wrote:
>
> Badshah
> What happens if you SELECT UNIQUE?
> Ian
>
> Badshah wrote:
> >
> > Hi EveryOne,
> >
> > I have the foll code fragment (ESQL/C code).
> > I have linked with ESQL 7.2 UC librariies on INFORMIX 7.2
> > running on HPUX 10.10.
> >
> > void
> > MyFunc()
> > {
> > DECLARE CURSOR cursor1
> > SELECT * from <tbl_name> where <field1> = ?
> > ORDER BY field2, field3, field4;> >
> > OPEN CURSOR cursor1 using <value_for_field1>;
> >
> > while (1)
> > {
> > FETCH CURSOR cursor1 into <record_struct>;
> > UPDATE <tbl_name> set <field1> = <new_value_for_field1>
> > WHERE <primary_key_conditions>
> > /* the above line is meant to update the field1
> > * to the new value in the same table so that
> > * it is not read again in subsequent invocations of
> > * this function
> > */
> > }
> > }
> >
> > Now the problem:
> > ----------------
> > The FETCH cursor returns some rows multiple times
> > (the number of times is random). Even the occurence of
> > reading the same row multiple times is random.
> >
> > Why and how could this be possible?
> > Is there any way to overcome it?
> >
> > Thanks in advance.
> >
> > V Vijayakumar
> > 14th Jan 1997 @ 1145 hrs
I'm confused, but be aware that when you open a cursor, Informix reads
the table. If you update a row in that table, the row is updated, BUT,
the cursor does not "see" this update until the cursor is re-opened.