PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → H duplicate error message
H duplicate error message
Iniciado por guest, 26,may. 2018 18:57 - 5 respuestas
Publicado el 26,mayo 2018 - 18:57
Instead of getting a duplicate error id like to perform a action however no mather what i try i keep getting the duplicate error can i disable the error somehow(witouth giving in)?

Store=db
Store.name =key unique

Store.name=”MyStore”

IF HAdd(Store) =False AND HErrorDuplicates() = True THEN
HModify(Store)

END
Publicado el 26,mayo 2018 - 19:57
Hi WD Express (new)... wow, that's a mouthful

look at the hOnError function for that

Best regards
Publicado el 26,mayo 2018 - 22:36
Hi WD Express (new)

Why don't you try it the other way round?
If you can read the record THEN HModify it ELSE HAdd a new record END In any case: to avoid the duplicate error, you'll have to check for similar key existence by yourself before adding. Seek, don't read. HSeekFirst "is your friend".

Best regards
Ola
Publicado el 28,mayo 2018 - 09:20
Or:

If xxxx...new record then
HAdd(xxxx)
else
HModify(xxxx)
end
Publicado el 29,mayo 2018 - 11:07
There seem to exist mixed opinions about the reliability of a record's NewRecord property. At least in earlier versions. Is it considered safe now, always, in all situations? Since which version?

Search this site for "NewRecord".

Best regards
Ola
Publicado el 29,mayo 2018 - 13:02
Hi

the ..NewRecord property is NOT always reliable because the record is only 'NEW' in the sens that the current process doesn't know it. However, at the DB level, there are potentialy many processes creating records, and that property does NOT take them into account.

By example, you have a unique key on email address... And by mistake, two of your 'customer representatives' are creating the same customer record at the same time...

Neither side can know about the other so ..NewRecord will return true on each side, and yet you'll have a duplicate error when the second one does the hadd.

So that's a property to be use in VERY RESTRICTED cases (ie ONE user only, ONE process running only)

Best regards