Microsoft KB Archive/281898

= BUG: Missing Integers with SQL Statement When You SET COLLATE TO &quot;RUSSIAN&quot; =

Article ID: 281898

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 3.0b for Macintosh

-



This article was previously published under Q281898



SYMPTOMS
When you set the collation sequence to Russian (instead of Machine), queries in Visual FoxPro that compare integer fields in the WHERE clause of a SQL SELECT statement between two or more tables may not return all matching records.



RESOLUTION
To resolve this problem, use one of the following three workarounds:
 * Create index tags on the integer fields before you run the query.
 * Set the collation sequence to Machine before you run the query. To do this, issue the SET COLLATE TO &quot;Machine&quot; command in the program before you run the query.
 * Use a numeric field without decimal places instead of an integer field.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
  In the Config.fpw file (the Config.fpm file for a Macintosh), set the CodePage to Russian with the following command: CODEPAGE=1251  Save the Config.fpw file, and then quit and restart Visual FoxPro.  In a program (.prg) file, run the following code: CLEAR ALL CLEAR

** Store the current collation sequence to the variable yyy.

yyy=SET(&quot;collate&quot;)

** Set collate to Russian, a collation sequence that illustrates ** the problem.

* Comment the next line for the second workaround. SET COLLATE TO &quot;Russian&quot; * Uncomment the next line for the second workaround. *SET COLLATE TO &quot;Machine&quot;

** Create two cursors, each with one integer field.

CREATE CURSOR t1 (in1 i)  * Uncomment the next line for the first workaround. *INDEX ON in1 TAG in1 CREATE CURSOR t2 (in2 i)  * Uncomment the next line for the first workaround. *INDEX ON in2 TAG in2

** Populate each cursor with 2000 records, inserting the loop counter ** into the integer field.

FOR x=1 TO 2000 INSERT INTO t1 (in1) VALUES(x) INSERT INTO t2 (in2) VALUES(x) ENDFOR

** Use the SELECT statement to join the two tables.

SELECT * FROM t1,t2 WHERE in1=in2 INTO CURSOR t3

** Check _Tally to see how many records the query returned.

WAIT WINDOW STR(_Tally)+&quot; records returned by the query&quot;

** Start the loop to determine what records are missing.

x=0 SCAN x=x+1 IF NOT in1=x WAIT WINDOW &quot;Missing integer&quot;+ STR(x) x=in1 ENDIF ENDSCAN

** Set collate back to its original setting.

SET COLLATE TO yyy



The query should return 2000 records; however, only 1,993 records appear. Integers 22, 278, 534, 790, 1046, 1558, and 1814 are missing.

