Passing Variables to SELECT-SQL w/o Using Macro Substitution

ID: Q114670


The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0, 5.0, 6.0
  • Microsoft FoxPro for Windows, versions 2.5b, 2.6
  • Microsoft FoxPro for MS-DOS, versions 2.5b, 2.6
  • Microsoft FoxPro for Macintosh, version 2.5b


SUMMARY

When you are passing variables to a SELECT - SQL command, you may have to call the command and programmatically pass criteria to it rather than coding such criteria directly. In many such instances, you may not want to use macro substitution.

The programs below show how to pass variables to a SELECT - SQL command without using macro substitution.


MORE INFORMATION

The programs below are provided as an example of calling a FoxPro SELECT - SQL command with the selection criteria contained in variables. They employ name expressions and the EVALUATE function instead of macro substitution.

FoxPro 2.x Example




   *THIS PROGRAM USES THE TUTORIAL DATABASE 'CUSTOMER'
   SET TALK OFF     && stop echo to screen
   x="STATE"
   y="FL"
   SELECT * FROM CUSTOMER; 
HAVING EVALUATE(x)=(y); INTO CURSOR OUTPUT

   BROWSE 


Visual FoxPro Example




   *THIS PROGRAM USES THE 'CUSTOMER'DATABASE in the SAMPLE\DATA Directory
   SET TALK OFF     && stop echo to screen
   x="Country"
   y="UK"
   SELECT * FROM CUSTOMER; 
HAVING EVALUATE(x)=(y); INTO CURSOR OUTPUT

   BROWSE 


The output will contain records where the contents of the field whose name is contained in variable x are equal to the contents of variable y.

Additional query words: VFoxWin FoxMac FoxDos FoxWin ARGUEMENT

Keywords : kbcode FxprgSql
Version : MACINTOSH:2.5b; MS-DOS:2.5b,2.6; WINDOWS:2.5b,2.6,3.0,5.0,6.0
Platform : MACINTOSH MS-DOS WINDOWS
Issue type :


Last Reviewed: December 29, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.