Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Too many args in my complex SQL
Message
De
30/08/2007 12:36:37
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01251397
Message ID:
01251418
Vues:
19
Thanks Naomi.

>Hi Terry,
>
>AFAIK Borislav and Rick spotted the exact error, but I would still try to re-code it from the maintenance point of the view.
>
>>Hi Sergey. Thanks for the attention.
>>
>>You see the old snippet below, commented out?
>>So, if ET.Date was between the curr period start and end dates it was summed.
>>Similarly, if it fell between the prev period start and end dates it was summed.
>>
>>However, there might not be start curr period date, or end prev period date so, respectively, the ET.Date would need to be between the end prev period and end curr period, or start prev period and start curr period.
>>
>>Whether or not my logic is flawed here (:-), I amn experimenting to get mself out of an anomolie that's not worth (or really possible easily) to explain here, and I mainly want to know where the niggling error is. That's why I've elaborately laid out the code, to saee what args go with what funcs more easily.
>>
>>Cheers
>>
>>>Hi Terry,
>>>
>>>Your SQL doesn't match what you are saying you're trying to do. Can you clarify your intentions?
>>>Anyway, you should redefine begining and end of each period instead of complication query itself.
>>>
>>>>Got this complex SQL. The field ET.Number is to be summed if it falls between the prev. start and end dates, or between the curr. start and end dates.
>>>>
>>>>That's how it stood and worked OK. BUT, sometimes the date ranges can be open-ended, eg there's a prev. period start date but "open-ended" end date. So had to extend the SQL to say, like, "if ther's no end to prev period make sure the date is before the start of the curr. period)
>>>>
>>>>Trouble is:
>>>>"too many arguments" error. Can't figure where it's going wrong. Need another pair of eyes looking over my shoulder. Can anyone spot the error?
>>>>
>>>>'ppreciate it.
>>>>
>>>>
>>>>SELECT ET.Operator, ET.Route, ET.Class, ET.Date, ET.RorF, op.Desc as OpDesc, ;
>>>>       Thisform.lmGetServeType( ET.Operator, ET.Route, ET.Date) as ServeType, ;
>>>>       IIF( ET.Route == ET.Mcl_Rte, "    ", ET.Mcl_Rte) as ContrNum, ET.Family, ;
>>>>       SUM( IIF( BETWEEN( ET.date, ;
>>>>	                 IIF( not EMPTY( ldStartCurr), ;
>>>>		             ldStartCurr, ;
>>>>	                      ldEndPrev), ;
>>>>	                 ldEndCurr), ;
>>>>	        ET.Number, ;
>>>>	        0000000) ) AS CurrPass, ;
>>>>       SUM( IIF( BETWEEN( ET.date, ;
>>>>		        ldStartPrev, ;
>>>>		        IIF( not EMPTY( ldEndPrev), ;
>>>>			    ldEndPrev, ;
>>>>			    ldStartCurr), ;
>>>>	        ET.Number, ;
>>>>	        0000000) ) AS PrevPass ;
>>>>  FROM ETMData ET ;
>>>>	JOIN Operator op ;
>>>>	On   ET.Operator 	== op.Code ;
>>>>  WHERE ET.Operator 	== lnOpCode ;
>>>>  AND	(    ET.date BETWEEN ldStartCurr and ldEndCurr ;
>>>>  	  OR ET.date BETWEEN ldStartPrev and ldEndPrev) ;
>>>>  AND not DELETED() ;
>>>>  ORDER BY ET.Operator, OpDesc, ET.Route, ET.Class ;
>>>>  GROUP BY ET.Mcl_Rte, OpDesc, ET.Operator, ET.Route, ET.Class ;
>>>>  INTO CURSOR csrETMPassengers NOFILTER READWRITE
>>>>
>>>>
>>>>For ref. the last 2 SUM()s were as follows:
>>>>
>>>>* 30/08/07 SUM( IIF( BETWEEN( ET.date, ldStartCurr, ldEndCurr), ET.Number, 0000000)) AS CurrPass, ;
>>>>* 30/08/07 SUM( IIF( BETWEEN( ET.date, ldStartPrev, ldEndPrev), ET.Number, 0000000)) AS PrevPass ;
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform