Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What are the best indexes to have for a filter ?
Message
De
11/01/2005 11:45:20
 
 
À
11/01/2005 10:30:34
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
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 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
00975956
Message ID:
00976076
Vues:
8
Hi Hilmar,

I know that combining a variable number of ANDs can be tricky for filters, that's why I asked Franco about the possibility to use a cursor in stead. I discovered some years ago that you can SELECT from a cursor with the same name as your result cursor, which makes this very easy for cursors, given ALL the different conditions are ANDs:
*laCondition is an array of condition, each element is ONE legal condition, for instance "Department=1"
lcCondition=laCondition(1)
SELECT * FROM yourTable where &lcCondition INTO CURSOR yourResult ReadWrite
FOR x=2 to ALEN(laCondition)
  lcCondition=laCondition(x)
  SELECT * FROM yourResult where &lcCondition INTO CURSOR yourResult ReadWrite
ENDFOR
>>Hi Tore.
>>
>>Sorry for the delay in answering.
>>
>>The problem is that if I do not use $ and filter on Department+Section+Unit, I will end up with a huge filter string. I can't build up the filter for department, section, and unit individually.
>>
>>If i have the three individual indexes and then do the filter as it was originally (Department+Section+Unit $ cDepSecUnit), it still won't be good ?
>>
>>
>>Thanks
>
>You can easily use a variable WHERE clause, with macro substitution, i.e., the "&" sign.
>
>For example:
>
>
>lcDepartment = ThisForm.TxtDepartment.Value && i.e., based on user input
>if not empty(lcWhereClause)
>  lcWhereClause = "Department = " + lcDepartment
>endif
>...
>select
>  ...
>  where &lcWhereClause
>  ...
>
>
>Combining two or more expressions with AND is a little more tricky, but perhaps this gives you the general idea.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform