Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
6
Erster Beitrag:
vor 1 Monat, 3 Wochen
Letzter Beitrag:
vor 1 Monat, 3 Wochen
Beteiligte Autoren:
Ola, Fabrice Harari, Ericus, WD Express (new)

H duplicate error message

Startbeitrag von WD Express (new) am 26.05.2018 16: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

Antworten:

Hi WD Express (new)... wow, that's a mouthful

look at the hOnError function for that

Best regards

von Fabrice Harari - am 26.05.2018 17:57
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

von Ola - am 26.05.2018 20:36
Or:

If xxxx...new record then
HAdd(xxxx)
else
HModify(xxxx)
end

von Ericus - am 28.05.2018 07:20
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

von Ola - am 29.05.2018 09:07
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

von Fabrice Harari - am 29.05.2018 11:02
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.