Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Efficient coding problem
Message
De
16/11/2000 04:35:02
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00442342
Message ID:
00442531
Vues:
8
Nadya,

You could have only one program and pass a parameter to define the query type. Based on the parameter, you could define fieldnames, selection criteria, etc. Then, in your SQL SELECT you use these values. Here's the basic approach:

LPARAMETER tcQueryType

DO CASE
CASE tcQueryType == "S"
lcFieldName = "nAmount"
lcFieldNameAs = "nAmountPur"
lcWhere = " WHERE cSource = 'S' "
CASE tcQueryType == "M"
lcFieldName = "nAmount"
lcFieldNameAs = "nAmountRef"
lcWhere = " WHERE cSource = 'M' "
OTHERWISE
lcFieldName = "nAmount"
lcFieldNameAs = "nAmountAll"
lcWhere = ""
ENDCASE

SELECT nAmount AS (lcFieldNameAs);
FROM MyTable;
&lcWhere;
INTO MyCursor

*-- or if you have different input fields:
SELECT &lcFieldName AS (lcFieldNameAs);
FROM MyTable;
&lcWhere;
INTO MyCursor

Hope this helps.
Daniel
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform