FORUMS PROFESSIONNELS
WINDEV
,
WEBDEV
et
WINDEV Mobile
Accueil
|
Messages récents
|
Connexion
|
Déconnexion
|
Français
Accueil
→
WINDEV 2024
→
[WD20] Unique Key
[WD20] Unique Key
Débuté par Curtis, 03 sep. 2015 21:24 - 4 réponses
Connectez-vous…
Curtis
#1
Posté le 03 septembre 2015 - 21:24
I have a Barcode field that is a unique key. It's in a file called Test. If I try to add duplicate Barcodes via inline editing in the control center or by HAdd()/HModify() I get a duplicate key warning. But when I add duplicate Barcodes via an sql query I do not get a warning and the duplicate record are entered into the file.
Is this supposed to happen? Shouldn't the sql code fail on account of the duplicate keys?
Signaler
0
0
GuenterP
#2
Posté le 04 septembre 2015 - 06:55
Hi, you have to take in account that empty barcode fields are "key values" as well and two empty barcode fields will trigger a duplicates error. Afaik, HFSQL has no way to ignore empty keys / NULL keys for an otherwise unique key-item. Workaround: make the key item a key with duplicates allowed but make sure by programming that only unique values are fed and empty key values are accepted.
Signaler
0
0
Fabrice Harari
#3
Posté le 04 septembre 2015 - 11:53
Hi Curtis,
Your question makes me think that you did not use the hcheckduplicates option in your hexecutequery. You should read all the details about it in the help.
However, PCSoft help advise to use hadd/hmodify/hedelete for all writing operations instead of queries (and it's much simpler to manage in your code, as an update query with hcheckduplicate forces a transaction, and you then have trouble knowing on which record of the query you got a duplicate error and...) well, you get the drill
Best regards
Signaler
0
0
Curtis
#4
Posté le 04 septembre 2015 - 16:07
Thanks Fabrice. Unfortunately I have to use queries when dealing with multiple records as it is much faster than looping throuh h functions.
Signaler
0
0
Curtis
#5
Posté le 04 septembre 2015 - 16:13
oops
Signaler
0
0
→ Revenir à WINDEV 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (précédentes versions)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Type de recherche
Uniquement les sujets
Tous les messages
Période de recherche
Date indifférente
Moins d'une heure
Moins de 24 heures
Moins d'une semaine
Moins d'un mois
Moins d'un an
Annuler
Aperçu de votre message
Ajouter une image
Importer une image depuis une URL
Envoyer une image depuis un fichier de votre disque
Déposez ici un fichier ou cliquez sur "Parcourir..."
ou
Annuler
0%
WLangage
SQL
XML, HTML
JAVA, Javascript
Texte