Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why these two commands will give different results
Message
From
04/12/2006 20:25:51
Mike Yearwood
Toronto, Ontario, Canada
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01174441
Message ID:
01174815
Views:
9
>>>>>What is the exact difference between two?
>>>>
>>>>>I do need to set order for SQL-Select using OLD style indexes (IDX). That was discussed recently on UT and Hugo R helped me to understand that. For these tables we're using old style IDX indexes.
>>>>
>>>>I think you need to SET INDEX TO to open the .idx so it can be used for Rushmore. I can't prove that at this moment.
>>>>
>>>>I'm pretty sure you don't need SET ORDER.
>>>
>>>Let me try without, but I'm not yet sure it's relevant. E.g. with or without order it should still produce the correct result, what do you think? When why I got two wrong invoices listed as mismatch and why I can not reproduce the problem in the command window for the mismatched invoices, but do receive exactly the same two invoices as wrong. I really can not understand what's going on.
>>
>>What if the .idx file wasn't updated? The query may pull the correct result, but the seek and sum while won't.
>
>True, but as I said, the Inv_No and Salesman fields are not touched in this procedure and somehow Select SUM gets two records where in one case the salesman in the table is different than passed value and in the other case the inv-no doesn't exist at all. When I run these selects in the command window they produce no results. That's why it's very strange.

Without the indexes select will work. Without the indexes sum while will only work if the data is sorted. Without the indexes, seek cannot be done.

The following demonstrates that having the index open will allow Rushmore to use it regardless of SET ORDER. That is the way it's always been. The structural CDX is open, but SET ORDER is not required for Rushmore optimization. In fact, it's irrelevant because VFP SQL reopens the cursors itself.
CLEAR
*Create table no .idx files.

LOCAL lcSetSafety
lcSetSafety = SET("SAFETY")

SET safety off
CREATE TABLE NAOMI FREE (cField1 c(10))

LOCAL m.lnI
FOR m.lnI = 1 TO 5
  INSERT INTO NAOMI (cField1) VALUES (TRANSFORM(m.lnI))
ENDFOR

*No indexes
SYS(3054,1)
SELECT * FROM NAOMI WHERE UPPER(cField1) = '3' INTO CURSOR c_Temp
SYS(3054,0)

*Index .idx

SELECT naomi
INDEX ON UPPER(cField1) TO cfield1.idx

SET ORDER TO 0

*.IDX NO SET ORDER
SYS(3054,1)
SELECT * FROM NAOMI WHERE UPPER(cField1) = '3' INTO CURSOR c_Temp
SYS(3054,0)

SELECT naomi

SET INDEX TO cfield1.idx
*.IDX NO SET ORDER
SYS(3054,1)
SELECT * FROM NAOMI WHERE UPPER(cField1) = '3'  INTO CURSOR c_Temp
SYS(3054,0)

SET SAFETY &lcSetSafety.
Try the query without the indexes and without set order. That should give you the correct result. Then see about adding the .idx via SET INDEX not via SET ORDER
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform