>>From a method of form. It doesn't matter if I compile and run as a separate prg nor add chr(10). I also thought an SQL could contain 4K+ chars :(
>>Query builder might not have a problem but here there is an aggregation function for 186 cols which I believe to be the problem. For you to reproduce it you can try code portion below :
>
>Hi Cetin,
>
>I just tried it on mine and it does not crash in VFP 5.0a and VFP6, SP4 (NT 4.0 Workstation).
>
>But I also have problems with long SQL (but much shorter than yours, though) in one old program which runs for years. The SQL runs in a loop and VFP crashes on randomly with similar error message (...memory could not be "written")
Thanks for heads up. I rechecked my version and it was 5.0! I'm afraid I lost SP files for the moment. Unfortunately crashes here on every try (including clean boot). During seeking a workaround I found that it's not related with the length of SQL but count of sum()s. It works with 120 fields, crashes with 140. Didn't try further and applied this worakround :
store '' to lcPatt1, lcPatt2, lcPattx
FOR ix = 0 to 185
if ix < 93
lcPatt1 = lcPatt1 + ',sum(T'+padl(ix,3,'0')+') as T'+padl(ix,3,'0')
else
lcPatt2 = lcPatt2 + ',sum(T'+padl(ix,3,'0')+') as T'+padl(ix,3,'0')
endif
lcPattx = lcPattx + ',T'+padl(ix,3,'0')
ENDFOR
SELECT f1,f2 &lcPatt1 ;
FROM myCursor ;
group by 1, 2 ;
into cursor myCursor1 ;
nofilter
SELECT f1,f2 &lcPatt2 ;
FROM myCursor ;
group by 1, 2 ;
into cursor myCursor2 ;
nofilter
SELECT a.f1,a.f2 &lcPattx ;
from myCursor1 a ;
inner join myCursor2 b ;
on a.f1=b.f1 and a.f2=b.f2
Cetin