>Function getsum is pretty usual, also has sql inside, not touching aliasis
> inside the main sql,
With UDFs used in SELECT - SQL it's a good idea to "leave things as you found them". Your SELECT, although to an array, might still open the tables involved or USE AGAIN in another work area. Work area it leaves as "current" may not be predictable. The code added in bold below works around this:
Function getsum(rid,_s)
Local _smres[1],m.rss,<b>lnSelect
lnSelect = SELECT(0)</b>
_smres[1]=00000000.00000000
select sum(iif(prh.kol!=0,round(prh.smr/prh.kol*prhrsh.kol,2),00000000.00000000));
from dbf_ck!prh,dbf_ck!prhrsh ;
where prh.str_id=prhrsh.strp_id and prhrsh.strr_id=rid into array _smres
m.rss=_smres[1]
if type('_smres')!='U'
release _smres
endif
<b>SELECT (lnSelect)</b>
return m.rss
If that doesn't help I can think of two other things:
- rather than simply REINDEXing (which may not fix subtle index corruption), issue DELETE TAG ALL and then reapply the indices from scratch.
- Scan your .DBFs for low level corruption, perhaps indicated by extended characters outside the valid range.
Regards. Al
"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov
Neither a despot, nor a doormat, be
Every app wants to be a database app when it grows up