MORE INFORMATION
Steps to Reproduce Behavior
NOTE: The following causes Visual FoxPro to exit, and you could lose
unsaved data.
Run the following code from a program (.prg) file:
CREATE CURSOR cc (KEYF N(1), inr N(3), DATE d)
INSERT INTO cc VALUES (1, 234, DATE())
INSERT INTO cc VALUES (1, 252, DATE()+1)
INSERT INTO cc VALUES (1, 45, DATE()+2)
INSERT INTO cc VALUES (1, 40, DATE() - 2)
INSERT INTO cc VALUES (1, 50, DATE() - 2)
SELECT MAX(inr) AS mx, MIN(inr) AS mn FROM cc INTO CURSOR q1
SELECT v1.DATE, v1.inr, ;
v2.DATE, v2.inr, ;
v1.DATE - v2.DATE AS days, ;
v1.inr - v2.inr AS net ;
FROM cc v1, cc v2 ;
WHERE v1.inr = (SELECT mx FROM q1);
AND v2.inr = (SELECT mn FROM q1)
Under Windows NT 4.0, Visual FoxPro terminates on the SELECT statement with
an error like the following:
vfp.exe
Exception: access violation (0xc0000005), Address 0x0044817c
Under Windows 95, Visual FoxPro terminates on the SELECT statement with an
error like the following:
VFP caused an invalid page fault in module VFP.EXE at 0137:00440940.
The address (either the 0x0044817c or 0137:00440940 in the preceding example)
will vary with the specific Visual FoxPro 5.0x build number.
The error does not occur in Visual FoxPro 3.0x and one record is returned.
Workaround
Adding the IN clause prevents the error from occurring. Here is a possible
work around for this problem:
CREATE CURSOR cc (KEYF N(1), inr N(3), DATE d)
INSERT INTO cc VALUES (1, 234, DATE())
INSERT INTO cc VALUES (1, 252, DATE()+1)
INSERT INTO cc VALUES (1, 45, DATE()+2)
INSERT INTO cc VALUES (1, 40, DATE() - 2)
INSERT INTO cc VALUES (1, 50, DATE() - 2)
SELECT MAX(inr) AS mx, MIN(inr) AS mn FROM cc INTO CURSOR q1
SELECT v1.DATE, v1.inr, ;
v2.DATE, v2.inr, ;
v1.DATE - v2.DATE AS days, ;
v1.inr - v2.inr AS net ;
FROM cc v1, cc v2 ;
WHERE v1.inr IN (SELECT mx FROM q1);
AND v2.inr IN (SELECT mn FROM q1)
(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Jim
Saunders, Microsoft Corporation