Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unique but not unique
Message
 
 
À
21/08/2008 13:30:05
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01340637
Message ID:
01340856
Vues:
11
>>>How would you insure that the entries in a given field are unique OR blank? That is, multiple blank records are OK but if data is entered, it must be a unique value. Setting up a candidate index doesn't work due to the blank fields.
>>
>>SELECT cField, CNT(*) AS nCnt ;
>> FROM YourTable ;
>> WHERE NOT EMPTY(cField) ;
>> GROUP BY cField ;
>> HAVING nCnt > 1 ;
>> INTO CURSOR Dups
>>
>>This gives you a list of duplicate values.
>>
>>Tamar
>
>Thanks Tamar. This would find duplicates if there are any, but how would you prevent them in the first place? I'm thinking some kind of code in both update and insert triggers might be the way to go, but I'm not really sure.

Don,

I'm not sure if we can rely on record number in the trigger, but you may try using something close to my first idea inside the INSERT trigger.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform