Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Specifying index
Message
From
27/03/1997 16:21:55
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
27/03/1997 15:28:50
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00025872
Message ID:
00025950
Views:
26
>>>I am USEing a table, SCANning it, and in the scan performing a SELECT on another table using a value from the first as the search key. How do I specify an index for the second table?
>>> I have only used work areas limitedly and am not completely comfortable yet, should I be using the tables in different work areas? I never opened the second table anywhere except in the select statement.
>>>
>>>By the way- Thanks to everybody for all your help with my sometimes silly questions in the past. As a VFP beginner, I feel I would be stuck out on a limb without your help. This is especially aimed at Edward, Dave, Arnon, and everyone else who has been quick to respond to my problems.
>>
>>So, I'm assuming that the code looks something like:
>>
>>Sele 0
>>Use FILE1
>>set order to tag TAG1
>>go top (or seek initvalue)
>>
>>SCAN
>> SELECT fieldlist;
>> from FILE1,FILE2;
>> where FILE2.idfield = FILE1.idfield
>> into RESULTFILE
>> (manipulate RESULTFILE)
>>ENDSCAN
>>
>>If my assumption is correct, you don't need to specify an index tag on the second file. Fox will determine if an index tag that it needs for he select exists and will use it. For Rushmore to work properly, you don't want ANY index tag active on the second file.
>
>Pretty close. Here's the code.
>
>use memb shared
>local array districts(3)
>scan
> if len(alltrim(zipcode)) = 10 then
> SELECT zipdist.cdist, zipdist.sdist, zipdist.hdist;
> FROM temptest!zipdist;
> INTO array districts;
> WHERE zipcode = memb.zipcode
>
> replace mcdist with districts(1)
> replace msdist with districts(2)
> replace mhdist with districts(3)
> endif
>endscan
>
>So VFP is automatically using any indexes it needs? I wanted to be sure, because it runs SOOOO SLOOOOW. (930 records/min) . BTW- I am in the habit of separating all of my REPLACEs because I've never been able to get a single replace to work with more than one pair of fields. I have followed the syntax in help to the T and I get syntax errors.

Try this instead.
scan
if len(alltrim(zipcode)) = 10 then
m.zipcode=memb.zipcode
SELECT zipdist.cdist, zipdist.sdist, zipdist.hdist;
FROM temptest!zipdist;
INTO array districts;
WHERE zipcode = m.zipcode

replace mcdist with districts(1)
replace msdist with districts(2)
replace mhdist with districts(3)
endif
endscan

Did the earlier code work? I thought you'd have to include memb in the SQL's FROM clause. Can you explain the purpose of the code. I think you could use another method to do this instead of the SQL inside a loop.

There shouldn't be any problem with using 1 replace command. Did you want the replace command to operate on the cursor produced by the SQL?

Mike Yearwood Toronto, Ontario Canada (co-founder of the Toronto Foxpro User's Group)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform