PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → HReadSeek returning wrong match
HReadSeek returning wrong match
Iniciado por sadi, 03,mar. 2016 18:28 - 5 respuestas
Publicado el 03,marzo 2016 - 18:28
I am doing a hReadSeek in a table to see if a value already exists. I am searching a text field with nominal sizes like 1x1, 2x1, 3x3 etc.

HReadSeek(IS_product_size, size_alias, sProductSize_ToBeInserted ,hIdentical)


Even with hIdentical, the search is returning true when comparing 1/2x1/2 with 12x12, or 3/4x1 with 34x1.
It is ignoring the "/" for some reason.

I am trying to google the answer but didn't find anything
Miembro registrado
34 mensajes
Publicado el 21,marzo 2016 - 12:03
Hi Giorgi,

In this case, it is better to use HReadSeekFirst

When using HReadSeek:
Positions on the first record of a data file whose value for a specific item is greater than or equal to a sought value (generic search).


When using HReadSeekFirst:
Positions on the first record of a data file whose value for a specific item is strictly equal to a sought value (exact-match search).


RESULT is a boolean

RESULT = HReadSeek(IS_product_size, size_alias, sProductSize_ToBeInserted ,hIdentical)

// RESULT = TRUE because it searches
// size_alias >= sProductSize_ToBeInserted
// and not
// size_alias == sProductSize_ToBeInserted
Publicado el 21,marzo 2016 - 14:39
Hi Giorgi, Hi Tim

the reason for the problem is simply that your key is defined in the
analysis as not respecting punctuation. You'll have to change that.

As for the hreadseekfirst, it's not usefull here and will have the same
wrong result if the key is not changed. What you need to use is the
hidentical option of the hreadseek, which is already done.

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com


On 3/21/2016 6:03 AM, Tim wrote:
Hi Giorgi,

In this case, it is better to use HReadSeekFirst

When using HReadSeek:
Positions on the first record of a data file whose value for a specific
item is greater than or equal to a sought value (generic search).


When using HReadSeekFirst:
Positions on the first record of a data file whose value for a specific
item is strictly equal to a sought value (exact-match search).


result is a boolean

result = HReadSeek(IS_product_size, size_alias,
sProductSize_ToBeInserted ,hIdentical)

// RESULT = TRUE because it searches // size_alias >=
sProductSize_ToBeInserted
// and not // size_alias == sProductSize_ToBeInserted
Miembro registrado
34 mensajes
Publicado el 21,marzo 2016 - 17:24
Fabrice Harari wrote:
Hi Giorgi, Hi Tim

the reason for the problem is simply that your key is defined in the
analysis as not respecting punctuation. You'll have to change that.

As for the hreadseekfirst, it's not usefull here and will have the same
wrong result if the key is not changed. What you need to use is the
hidentical option of the hreadseek, which is already done.

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com



Hey Fabrice,

thanks for your reply.

After testing it, it is indeed the key that needed to be changed.

I still have a question, thought: is there a reason to use HReadSeek with hIdentical instead of HReadSeekFirst in this case?

Kind regards
Mensaje modificado, 21,marzo 2016 - 17:25
Publicado el 21,marzo 2016 - 19:31
Hi Tim,

hreadseek is used when you need ONE result, hidentical when you want the
exact match.

hReadseekFirst is used when you want to do a hreadnext in a loop
afterwards...

But that's really a relative answer, because hreadseekfirst is a
"relatively" new syntax that has been added to allow another way to do a
hfilter/hreadfirst/next, and it's logic is a little different.

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com


On 3/21/2016 11:24 AM, Tim wrote:
Fabrice Harari wrote:
Hi Giorgi, Hi Tim

the reason for the problem is simply that your key is defined in the
analysis as not respecting punctuation. You'll have to change that.

As for the hreadseekfirst, it's not usefull here and will have the same
wrong result if the key is not changed. What you need to use is the
hidentical option of the hreadseek, which is already done.

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com



Hey Fabrice,

thanks for your reply.
After testing it, it is indeed the key that needed to be changed.

I still have a question, thought: is there a reason to use HReadSeek
with hIdentical instead of HReadSeekFirst in this case?

Kind regards
Miembro registrado
34 mensajes
Publicado el 22,marzo 2016 - 09:53
Fabrice,

thanks again for the info!


Kind regards,

Tim