Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 8 Monaten, 1 Woche
Letzter Beitrag:
vor 8 Monaten
Beteiligte Autoren:
Jose Maldonado, Chris cordes, GuenterP, Fabrice Harari

How to prevent the Duplicate Record screen?

Startbeitrag von Jose Maldonado am 10.10.2017 13:51

I am importing data from an Excel file into my database.
In the process I encounter duplicates that I want to ignore.
I am using the following code (after assigning the values):

IF HAdd(BVS_BOSS_LOAD) = False THEN
IF HErrorDuplicates() = True THEN
CONTINUE
END
ELSE
CONTINUE
END

All I need is that the process to ignore the duplicate record and
continue with the next record but it pops up a duplicate record
screen.

THNX !!
JoeMaldo

Antworten:

Hi Jose,

I'm doing this all the time! No such messages ...

The trick is to take a peek into the file before saving anything to the file.


MyPosition is 4-byte int
.
.
MyPosition = HSavePosition(MyFile)
IF HReadSeekFirst(MyFile, MyKey, MyUniqueKeyValueToBeSavedinFile) THEN
// this is the potentially dangerous point, the key value to be saved is already there!
IF MyPosition > -1 THEN HRestorePosition(MyPosition)
// That's it. No save occurs
ELSE
HAdd(MyFile)
// depending on the logic, you could insert a HRestorePosition(MyPosition) here
END



Of course, if the record to insert is identical to that you already have in the file and an update doesn't hurt, then a simple HSave(MyFile) is sufficient!

von GuenterP - am 10.10.2017 14:16
Hi

you can either :
- do a hreadseek first and do the hadd only if not there
- or DEACTIVATE the automatic error handling of HF before using your existing code. Right now, you are testing for the duplicates error but the automatic error handling is doing TOO, and BEFORE you

Best regards

von Fabrice Harari - am 10.10.2017 14:52
hOnError(BVS_BOSS_LOAD,hErrDuplicates,"SkipDUpes")

... Loop start ...
IF HAdd(BVS_BOSS_LOAD) = False THEN
CONTINUE
END
END
... Loop end ...

hOnError(BVS_BOSS_LOAD,hErrAll)

...

Procedure SkipDupes()
result opEndProcess

HTH,
Chris C

von Chris cordes - am 10.10.2017 15:13
Guys,
Thank you for your help!
I solved the problem!!

von Jose Maldonado - am 18.10.2017 01:55
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.