This article was previously published under Q114670
This article has been archived. It is offered "as is" and will no longer be updated.
When you are passing variables to a SELECT - SQL command, you may have tocall the command and programmatically pass criteria to it rather thancoding such criteria directly. In many such instances, you may not want touse macro substitution.
The programs below show how to pass variables to a SELECT - SQL commandwithout using macro substitution.
The programs below are provided as an example of calling a FoxPro SELECT -SQL command with the selection criteria contained in variables. They employname expressions and the EVALUATE function instead of macro substitution.
FoxPro 2.x Example
*This program uses the Customer table from the Tutorial.SET TALK OFF && stop echo to screenx="State"y="FL"SELECT * ; FROM customer; HAVING EVALUATE(x) = (y) ; INTO CURSOR crsrFloridaBROWSE
Visual FoxPro Example
*!* This sample uses the Customer table in:*!* VFP 3/5 -- HOME() + "Samples\Data"*!* VFP 6 -- HOME(2) + "Data"SET TALK OFF && stop echo to screenx="Country"y="UK"SELECT * ; FROM CUSTOMER; HAVING EVALUATE(x)=(y); INTO CURSOR crsrUKBROWSE
The output will contain records where the contents of the field whose nameis contained in variable x are equal to the contents of variable y.