Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Locate + locate
Message
From
16/10/2007 17:57:44
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
16/10/2007 13:17:03
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
01260940
Message ID:
01261373
Views:
16
>>>>Is it possible to put an .OR. in the two commands locate
>>>>below, using only one locate commad ?
>>>>
>>>>
>>>>loca for AP.id = AP_CONTROL.id .and. ALLTRIM(AP.AP) = ALLTRIM(AP_CONTROL.AP) .and.;
>>>> ALLTRIM(ap.marca) = alltrim(ap_control.marca) .and.;
>>>> ALLTRIM(ap.modelo) = ALLTRIM(ap_control.modelo) .and. ap.serie = ap_control.serie
>>>>
>>>>
>>>> **************OR******************
>>>>
>>>>
>>>> loca for AP.id = AP_CONTROL.id .and. ALLTRIM(ap.marca) = alltrim(ap_control.marca).and. ap.serie = ap_control.serie
>>>
>>>Ho Moises,
>>>
>>>as I wrote yesterday, AVOID alltrim unless you really need it! I guess this change gives the same result AND is much faster:
>>>loca for AP.id     = AP_CONTROL.id    .and.  AP.AP=AP_CONTROL.AP    .and.;
>>>   ap.marca  = ap_control.marca .and.;
>>>   ap.modelo = ap_control.modelo .and. ap.serie = ap_control.serie
>>>If you get wrong results, it's becuase you have Set exact off. In that case you can use replace = with ==
>>>loca for AP.id = AP_CONTROL.id    .and.  AP.AP==AP_CONTROL.AP .and.;
>>>   ap.marca  == ap_control.marca .and.;
>>>   ap.modelo == ap_control.modelo .and. ap.serie = ap_control.serie
>>>With Set exact off, which most programmer has as default, you must be aware that trim('aaa')=trim('a') will return .T., which in your case probably is not what you expect. On the other hand 'aaa'=='a' will return .F..
>>>
>>>BTW, if you are aware of this, and your command gives you the correct answer, please ignore tis message. But you should be aware that the use of alltrim in this case means that you lose Rushmore optimizing, meaning that your program will run much slower than it could have done.
>>
>>As you are probably aware, as long as he pads the index commands and expressions he can get Rushmore optimization.
>>
>>So with existing indexes INDEX ON PADR(ALLTRIM(marca),10) TAG IXMARCA in both tables...
>>
>>LOCATE FOR PADR(ALLTRIM(ap.marca),10) = PADR(alltrim(ap_control.marca),10) will be Optimized.
>
>Yes, but as you also are aware of, padr(alltrim(yourfield),10) is exactly the same as yourfield if len(yourfield)=10. So what's the point? I think that you agree that it's better to simply skip the alltrim?

Ah! Not always so! If the user entered " Yearwood" and I didn't alltrim() it in the validation, I'd need the alltrim() in the index, and have to pad it's length.

Also this index padr(Alltrim(LastName) + ", " + alltrim(FirstName)),50) would also have to be padded. :)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform