Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
I am ashamed to ask: Variables
Message
De
18/07/2000 12:51:38
Cindy Winegarden
Duke University Medical Center
Durham, Caroline du Nord, États-Unis
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00393489
Message ID:
00393902
Vues:
17
Rox,

I've had situations where I needed to extract data from an SQL database for a list of about 100 patients. I have read access only to this data, so I could not upload my 100 PatId's and SELECT ... WHERE IN (SELECT * FROM MyHundred).

This is what I've done:
cMyWhereStatement = ;
    [WHERE Invoices.Idx_id IN (]

cMyIds = []
SELECT Patient_list
SCAN 
    cMyIds = cMyIds + [,"] + ALLT(STR(PatId)) + ["]  && Remove "'s for numeric
ENDSCAN
cMyIds = SUBSTR(cMyIds, 2) + [)]    && Remove extra comma on front
Then I add all the parts of the SELECT and send the statement to the SQL server. If I'm doing local data I use macro expansion: &cMySQLStatement.


>OK since we're on the subject here...
>Whenever I have a situation like Randall's or Nadya's where I want to check for existence/non-existence of a value in a list, I always try to work it out with a subquery like Cindy has shown here with either WHERE EXISTS or WHERE NOT EXISTS as appropriate. The reason being is both the SQL IN clause and VFP's INLIST function basically boil down to hardcoding.
>
>Back in VFP 5 I tried to get both INLIST() and IN() to work with variable values and never did get to work out. Anybody else know of a way to use either of these without hardcoding the list of values they use?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform