Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL sum() on 186 fields causes crash
Message
De
13/09/2000 12:19:47
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00415834
Message ID:
00415907
Vues:
27
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 :
CREATE cursor test (f1 c(1), f2 c(1))
lcPattx = replicate(',0',186)
SELECT f1,f2 &lcPattx ;
  FROM test ;
  into cursor Dummy nofilter
AFIELDS(aNewStruc)
lnTimeColStart = 3
FOR ix = lnTimeColStart to aLen(aNewStruc,1)
  aNewStruc[ix,1]='T'+padl(ix-lnTimeColStart,3,'0')
  aNewStruc[ix,2]='I'
ENDFOR
CREATE cursor myCursor from array aNewStruc
FOR ix=1 to 2
  APPEND blank
  SCATTER to aSetTimes
  FOR jx = lnTimeColStart to lnTimeColStart + 3
    aSetTimes[jx] = 1
  ENDFOR
  GATHER from aSetTimes
ENDFOR

lcPattx = ''
FOR ix = 1 to 186
  lcPattx = lcPattx + ;
    ',sum(T'+padl(ix-1,3,'0')+')'
ENDFOR
***
* Next crash
***
SELECT f1,f2 &lcPattx ;
  FROM myCursor ;
  group by 1, 2 ;
  into cursor myCursor1 ;
  nofilter
I seek a way to do by SQL.
Cetin


>How you call this SQL? '&' or PRG file compiling?
>
> In fact, SQL SELECT command may contain much more that 4K of characters. Never have had a problems with that in our query builder.
>
> Try to add chr(13) + chr(10), not just chr(13) to separate lines.
> In addition, I run such queries ONLY by putting them into PRG file, compiling and than running. Because VFP '&' (macro) does not works in many cases for multi-line commands.
> Finally, you do not need to separate all items. Just keep 1 line less than 255 characters.
>
>>I have an intermediate cursor with 192 fields. I need to 'SQL' sum fields 7-192. First I did this :
>>
lcPattx = ''
>>for ix = 1 to 186
>> lcPattX = lcPattx + ;
>>   ',sum(T'+padl(ix-1,3,'0')+') as T'+padl(ix-1,3,'0')
>>endfor
>>select f1,f2,f3 &lcPattX from ...
Then this :
>>
lcPattx = ''
>>for ix = 1 to 186
>> lcPattX = lcPattx + ;
>>   'sum(T'+padl(ix-1,3,'0')+') as T'+padl(ix-1,3,'0')+', ;'+chr(13)
>>endfor
>>_cliptext = lcPattX
and pasted the code. I even tried removing 'as ...' part. Total commandline length is 4199 at max. Both approaches crash VFP. Any ideas other than not using SQL ? TIA
>>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