PRB: EVALUATE() Function in WHERE Clause May Return Incorrect Data (271492)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 3.0
- Microsoft Visual FoxPro for Windows 3.0b
- Microsoft Visual FoxPro for Windows 5.0
- Microsoft Visual FoxPro for Windows 5.0a
- Microsoft Visual FoxPro for Windows 6.0
This article was previously published under Q271492 SYMPTOMS
When you use the EVALUATE() function in the WHERE clause of a SELECT - SQL command, Visual FoxPro may fail to return all matching rows. This may happen if there are matching rows but the record pointer is not on one of them at the time the SELECT is run.
RESOLUTION
For standard SELECT statements, this can be solved by using macro substitution instead of the EVALUATE() function, or by doing a LOCATE before the SELECT, as shown in the "Steps to Reproduce Behavior" section.
For views, the following syntax has been shown to work in some cases. First, set up the database as shown in "Steps to Reproduce Behavior," and then run the following code from the Command window or a program file:
lcCriteria = '.T.'
CREATE SQL VIEW macroTestView AS ;
SELECT * ;
FROM testTable ;
WHERE &?lcCriteria
CLEAR
USE macroTestView
? "All records"
LIST
lcCriteria = "BETWEEN(testTable.code, 'a', 'c')"
? lcCriteria
=REQUERY()
LIST
lcCriteria = "BETWEEN(testTable.code, 'd', 'f')"
? lcCriteria
=REQUERY()
LIST
REFERENCESFor additional information about using the EVALUATE() function and the SELECT - SQL statement, click the article numbers below
to view the articles in the Microsoft Knowledge Base:
125046 INFO: Macro Substitution, Name Expressions, and EVALUATE() Runtime Evaluation
114670 HOWTO: Pass Variables to SELECT-SQL w/o Using Macro Substitution
193079 FIX: Syntax Error with EVAL of ALL or LTRIM in SELECT-SQL
Modification Type: | Major | Last Reviewed: | 5/12/2003 |
---|
Keywords: | kbCodeSnippet kbDatabase kbpending kbprb kbSQLProg KB271492 |
---|
|