Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Searching all fields in a database
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00012278
Message ID:
00012314
Views:
33
>Boy we are critical of each other, no I will enjoy some.

Me?? Critical?? Not at all! I just thought of a more efficient
way (to my knowledge, of course :) No criticism intended!
>
>Robert,
>The guy wanted to search ALL fields not just indexed ones.

If the table contains 100 records or not more than 10 fields,
then I can agree on non-indexed search using SCAN/Locate/SQL...
But have you tried using those 3 on real-life tables with
hundreds of thousands of records trying to search for values
in all fields where the number of fields is inherited from
old Flat-File data structures? Try it :) You might as well take
a vacation after you click the OK button :)

>Your FOR NEXT loop should have been a DO WHILE set up as so:
>DO WHILE !EMPTY(TAG(jx))
> jx = jx +1
>ENDDO

It was proven on hundreds of test data that FOR loops are
more efficient than any other ones, especially the DO WHILE
ones because of the forced incrementation. Besides, I think
it's a typical case of coding methodology preferences, so I'll
leave it at that :)

>Also, an index key can be compound, OF VARYING DATA TYPES,
>TRIMmed or mabey even SOUNDEXed in HEBREW by some (OR ONE).
>You'll need some damn good error trapping for that one.

Regardless of the type of the index key you're looking for,
you are SEEKing for a value! The field that happens to have
an ORDER TAG will contain the same data type as your value!
If it's currently not the case, then all you need to do is
to create the missing index TAGs!
>
>It is also likely that if he wants to search all fields,
>he wants more than a STARTS LIKE search.

SEEK() does not provide for STARTS LIKE, unless you SET NEAR ON,
so this does not apply hear.

>
[some parts are removed to save space]
>
I have 14 tables each of which has a minimum of 130 fields and
50,000+ records. Try to extrapolate on the time elapsed after
this double-loop gets executed against either of those tables :)
>SCAN
> FOR jx = 1 TO FCOUNT()
> IF TYPE(FIELD(jx)) $ "CM" && Just check Charectoer and memos
> * IF tcFindMe $ UPPER(ConvertToChar(EVAL(FIELD(jx))))
> * The ConvertToChar() function is a secret and would
> * replace the IF directly above it.
> WAIT WINDOW "Found " + tcFindMe +" in Record " + ;
> LTRIM(STR(RECNO())) + " Field " +FIELD(jx)
> ENDIF
> ENDIF
> lnPlacesLooked = lnPlacesLooked + 1
> ENDFOR
> WAIT WINDOW NOWAIT ;
> "Looked In " +LTRIM(STR(lnPlacesLooked)) +" places so far"
>ENDSCAN
>
Some things are better be left unknown...NOT!!!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform