Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 8 Jahren, 3 Monaten
Letzter Beitrag:
vor 8 Jahren, 3 Monaten
Beteiligte Autoren:
Fabrice Harari, Ruben Sanchez Peña, Al, Dan M

How do you find an exact match base on multiple fields?

Startbeitrag von Dan M am 19.07.2009 01:41

I want to be able to find equal to based on multiple fields.

Example : I need to know if a SUPPLIER has offered us a PART NUMBER by a specific MANUFACTURER with a specific DELIVERY.

So I need to find an exact match on SUPPLIER_ID, PART_NUMBER, MANUFACTURER, & DELIVERY.

I have looked at HReadSeekFirst but it seems?? you can only search based on 1 field ... Is that true? and if so, how would to see if there is an exact match based on multiple fileds?



Hello Dan

It depends on the speed you need for the recovery of an item and if there are other combinations of key items.

For an exact match and the fastest response, create a composite (concantenated) index on the fields and the search on it

Then use HBuildKeyValue() to create the search key and HReadSeekFirst() to retrieve the record.

If you can accept slower response or have multiple combinations of key items then maybe create a few smaller index keys and search through the results to find the items by checking the records in the result set for a match on the remaining keys. e.g. create a composite index for SUPPLIER_ID + MANUFACTURER +DELIVERY and then search the result set for the matching item number

Windev seems to update its keys very quickly when adding records so you won't impose much overhead with a number of composite keys on a file.

You can check timings for various methods of key creation and retrieval using the profiler()

In terms of using the HReadSeek commands, HReadSeek returns a generic match which may not be the best appraoch for a composite key. HReadSeekFirst will return the exact match or nothing and Hfound() will show true or false. You can use the Hgeneric option in HReadSeekFirst to get a partial match for a composite key.

Also check out HFilter using HBuildKeyValue with HMinVal and HMaxVal to fill in the missing segments.


von Al - am 19.07.2009 03:00
Hi Dan. You can:

1) Define a Query with a parameter for each field you want ask.

2) Declare in your file a Composite Key and search the data by it.

von Ruben Sanchez Peña - am 19.07.2009 11:05
Hi Dan...

create a composite key in the analysis containing SUPPLIER_ID, PART_NUMBER, MANUFACTURER, & DELIVERY... According to the filed names, this key should be set as not accepting duplicates

For the search do simply a :
if hreadseek(MyFile,MyCompositeKey,[ValueOfSupplierID,ValueOfPartNumber,ValueOfManufacturer,ValueOfDelivery])=true then

Thats' all

Best regards

von Fabrice Harari - am 21.07.2009 18:12
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.