Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Record is out of range for optimistic buffering
Message
De
27/04/2000 02:51:17
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
27/04/2000 01:50:09
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00363681
Message ID:
00364011
Vues:
39
>I have tried tracing the methods but everthing seem fine
>
>this the code where the problem arises which is from tastrade grid class which I have used with only one minor change for evaluating the order for calculation.
>******************
>IF EMPTY(this.cFieldToSum)
> RETURN
>ENDIF
>
>LOCAL lnOldArea, ;
> lnOldRecNo, ;
> luKey, ;
> lcFieldToSum, ;
> lcOrder,;
> lstalk
>
>
>lnOldArea = SELECT()
>this.nColumnSum = 0
>lcFieldToSum = ""
>
>IF EMPTY(this.RecordSource)
> RETURN
>ENDIF
>
>*-- Select the alias specified in the grid's RecordSource property
>SELECT (this.RecordSource)
>
>lcOrder = ORDER()
>luKey = IIF(!EMPTY(lcOrder), EVAL(key(tagno())), "")
>lnOldRecNo = IIF(EOF(), 0, RECNO())
>lcFieldToSum = this.cFieldToSum
>
>lstalk = set('talk')
>set talk off
>*-- Total up the column and store the result
>*-- in the nColumnSum property
>IF !EMPTY(lcOrder) AND SEEK(luKey)
> SUM &lcFieldToSum. ;
> WHILE luKey = EVAL(key(tagno())) ;
> TO this.nColumnSum
>ELSE
> IF CURSORGETPROP("SOURCETYPE") = DB_SRCLOCALVIEW OR ;
> CURSORGETPROP("SOURCETYPE") = DB_SRCREMOTEVIEW
> *-- Grid is bound to a view
> SUM &lcFieldToSum. ;
> TO this.nColumnSum
> ENDIF
>ENDIF
>
>IF lnOldRecNo <> 0
> GO lnOldRecNo **********Error Occurs Here**********
>ENDIF
>
>SELECT (lnOldArea)
>if lstalk = 'ON'
> set talk on
>endif
>***********
>
>Rajesh


Rajesh,
You say it's optimistic buffering (and as far as I remember it's a must for wizard generated forms) but you don't say if it's a row or table buffering. My gut guess you're using row buffering. Say you have 100 records and add a new one which gets recno -1. As this method runs, "sum" moves the record pointer and an implicit tableupdate() occurs causing your "current row" to be 101 (in a multiuser environment might be higher). You store -1 to lnRecno which no longer exists after "sum". As a workaround either change your buffering to table or store a unique field value (ie: I also use PK like field for childs even if they're not used to link to some other table) that you can seek after sum.

OTOH I would never use a code something like this that moves the record pointer out of my will and unnecessarily does summing many times (if your child records count for a particular parent key increases users would start to wait more and more to get cursor back ). Instead sum once as parent changes using SQL, in field's valid or lostfocus add just the "difference" of old value and value to already summed value.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform