PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → HReadSeekFirst problem with composite keys and empty dates
HReadSeekFirst problem with composite keys and empty dates
Iniciado por guest, 30,jun. 2016 21:20 - 6 respuestas
Publicado el 30,junio 2016 - 21:20
Having a heck of a time figuring this out. I have a file (requests) with a composite key consisting of a store # field (integer) and a date fulfilled field (date). The idea was to use HReadSeekFirst to find an unprocessed record by store number. But it doesn't recognize an empty date for some reason. I have a table with 2 records in it, one with a blank date and one with a current date. If I do the following:

IF HReadSeekFirst(requests,storenumDateFulfilled,[7998,""])=False
RETURN // Not found or error
END
IF HFound(requests) = False THEN
RETURN // Not Found
END
IF requests.DateFulfilled <> "" THEN
RETURN
END

The HReadSeekFirst and HFound passes, but the DateFulfilled is the current date, NOT the empty date as desired. Any ideas? Is this a bug?
Publicado el 01,julio 2016 - 04:21
Hello Peter

I have never had much luck using the array method [] and I find that using HBuildkeyValue() is more reliable so you could try that instead

Regards
Al
Publicado el 01,julio 2016 - 08:52
Maybe you can try with this (don't use second parameter-date):
HReadSeekFirst(requests,storenumDateFulfilled,[7998],hGeneric+hLimitParsing))

Regards !
Publicado el 01,julio 2016 - 14:56
Thanks for the reply, but I did try both ways.
Publicado el 01,julio 2016 - 15:03
Thanks, I'll try your way. But I would still like to know why what I wanted to do didn't work. I may just have to change my search key to get around this problem.
Publicado el 02,julio 2016 - 20:42
Peter.
HFound() return False because hreadseekfirst() do exact search and with parameter
" " record such that can not be found. With parameter "hgeneric" you say hreadseekfirst() you try to find not exact record but closer equal and stop your search when you find first matching record with "hlimitparsing"

Regards !
Publicado el 03,julio 2016 - 07:17
Hi, since WD 5.5 I'm building composite keys a string keys by programming, even if parts of the key are numeric, dates etc. From v12 on I'm using triggers for that and I'm still doing so. A string as a "composite key" has the advantage that all of it can be inspected visually without pain. You can easily take care of empty dates and other funnies.