Information générale
Catégorie:
Codage, syntaxe et commandes
>>With the view parameters set as follows:
>>
>>vp_Active = .T.
>>vp_idnum = '*'
>>vp_last = 'A%'
>>vp_first = '*'
>>vp_middle = '*'
>>
>>shouldn't the following view definition return only records that have
>>lastname beginning with 'A' and empty(disdate)? It doesn't - it returns
>>records that have lastname beginning with 'A' regardless of disdate.
>>Am I missing something simple?
>>
>>SELECT Clients.cidnum, Clients.clastname, Clients.cfirstname,;
>> Clients.cmiddlename, Clients.cadmdate, Clients.disdate;
>>FROM cms!clients;
>>WHERE Clients.cidnum LIKE ?vp_idnum;
>> OR (UPPER(Clients.clastname) LIKE UPPER(?vp_last));
>> OR (UPPER(Clients.cfirstname) LIKE UPPER(?vp_first));
>> OR (UPPER(Clients.cmiddlename) LIKE UPPER(?vp_middle);
>> AND EMPTY(Clients.disdate) = ?vp_active)
>
>Actually, it's the middle name that is ANDed with the active field. Since the middle name comparison allways return .F., the result of the AND is .F. So you get all records that have last name beginning with "A".
>
>Try the following:
>SELECT Clients.cidnum, Clients.clastname, Clients.cfirstname,;
> Clients.cmiddlename, Clients.cadmdate, Clients.disdate;
>FROM cms!clients;
>WHERE Clients.cidnum LIKE ?vp_idnum;
> OR (UPPER(Clients.clastname) LIKE UPPER(?vp_last));
> OR (UPPER(Clients.cmiddlename) LIKE UPPER(?vp_middle));
> OR (UPPER(Clients.cfirstname) LIKE UPPER(?vp_first);
> AND EMPTY(Clients.disdate) = ?vp_active)
>
>HTH
Thanks to all who replied. Erik found the real problem with this syntax. The empty(clients.disdate) on the left side of the clause only gets evaluated once. What I had to do was add a logical field to the table and use it with the vp_active view parameter.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement