PROFESSIONAL NEWSGROUPS
WINDEV
,
WEBDEV
and
WINDEV Mobile
Home
|
Recent messages
|
Connect
|
Sign out
|
English
Home
→
WINDEV 2024
→
How to prevent the Duplicate Record screen?
How to prevent the Duplicate Record screen?
Started by Jose Maldonado, Oct., 10 2017 3:51 PM - 4 replies
Connect yourself…
Jose Maldonado
#1
Posted on October, 10 2017 - 3:51 PM
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
Report
0
0
GuenterP
#2
Posted on October, 10 2017 - 4:16 PM
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!
Report
0
0
Fabrice Harari
#3
Posted on October, 10 2017 - 4:52 PM
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
Report
0
0
Chris cordes
#4
Posted on October, 10 2017 - 5:13 PM
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
Report
0
0
Jose Maldonado
#5
Posted on October, 18 2017 - 3:55 AM
Guys,
Thank you for your help!
I solved the problem!!
Report
0
0
→ Go back to WINDEV 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (earlier versions)
Français
English
Español
Portuguesa
Close this window
Search type
Only topics
All the messages
Search period
Any time
Past hour
Past 24 hours
Past week
Past month
Past year
Cancel
Preview of your message
Adding an image
Import an image from a URL
Send an image from a file of your disk
Drop a file or click "Browse..."
or
Cancel
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Text