>>SELECT SUM(field) TO sfield FROM lv_diario INTO CURSOR query1
>
>Sorry is:
>
>SELECT SUM(field) AS sfield FROM lv_diario INTO CURSOR query1
I'm not sure why you are getting correct results when you add records. You shouldn't get correct results at all using table buffering and a SQL select. SQL select open the underlying tables/views again in a separate work area for several reasons (e.g. don't disturb record pointer, change index used for optimization purposes, etc.). Because of this, the underlying unchanged cursor is opened again not the one with the data modifications.
SUM works on the buffered table/view so its answer would be correct. The problem with this is it moves the record pointer to the end of the table/view. You'll have to reposition it to its starting point.
Larry Miller
MCSD
LWMiller3@verizon.netAccumulate learning by study, understand what you learn by questioning. -- Mingjiao