Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can someone tell me why this query does not work?
Message
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 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01589692
Message ID:
01589733
Vues:
60
>Hi all.
>
>I have beat my head on the keyboard for long enough. Here is the query (angle brackets have been replaced by square brackets for readability here)
>

Nothing jumps out at me, but that query is really hard to read. I'd probably rewrite it a bit and see if it doesn't help highlight the problem.
TEXT TO lcSQL TEXTMERGE NOSHOW PRETEXT 15
    SELECT ConvertDateTime(VEH.EvtDate, VEH.EvtTime) AS start_time, 
           ConvertDateTime(VEH.EvtDate, VEH.EvtTime) + GetDuration(VEH.duration) AS end_time, 
           ST.descr AS SvcType_dsc, 
           SVC.servref 
      FROM funeral!ServiceVehicle VEH 
           WITH (BUFFERING = .T.) 
      JOIN aserdet SVC 
           WITH (BUFFERING = .T.) 
        ON VEH.service_id = SVC.serviceid 
      JOIN psvctype ST 
        ON SVC.servtype = ST.code 
     WHERE VEH.VehCode =  '[[tcVehCode]]'  
       AND VEH.SvcVehID # [[tiSvcVehID]]  
       AND ConvertDateTime(VEH.EvtDate, VEH.EvtTime) < {[[ttEndTime]]} 
       AND (ConvertDateTime(VEH.EvtDate, VEH.EvtTime) + GetDuration(VEH.duration)) > {[[ttStartTime]]}
ENDTEXT 

FUNCTION ConvertDateTime(tdDate, tcTime)
   RETURN DATETIME(YEAR(m.tdDate), ;
                   MONTH(m.tdDate), ;
                   DAY(m.tdDate), ;
                   VAL(GETWORDNUM(m.tcTime, 1, ":")), ;
                   VAL(GETWORDNUM(m.tcTime, 2, ":")))
ENDFUNC

FUNCTION GetDuration(tcDuration)
   LOCAL lnDuration
   
   lnDuration = (VAL(GETWORDNUM(m.tcDuration, 1, ':')) * 3600) ;
              + (VAL(GETWORDNUM(m.tcDuration, 2, ':')) * 60))
              
   RETURN m.lnDuration
ENDFUNC
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform