Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checking some field for uniqueness
Message
De
12/06/2001 15:49:48
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00518556
Message ID:
00518564
Vues:
9
>Hi everybody,
>
>I had discussion on the same topic long time ago, but I have this problem again and I'm not sure, how to handle it.
>I have a table called AllFunctions. This table has FunctionID field (Primary autogenerated), FunName field and couple of other fields. FunName is the function name, which is entered by the user. My question is: how can I ensure uniqueness of this field? I want to have message at the time FuncionName is entered into the table and another check should be performed at the time of saving record. We have a class wgUniqueText, but I've just realized, that the code in it is not sufficient.
>
>Do you have ideas to share?
>
>Thanks in advance.
>
>P.S. Table has a regular index on FunName with expression upper(FunName)


Hi Nadya,
If you didn't want to use a candidate index and trap the errors you could try adding the following:
SELECT FunName ;
	FROM AllFunctions ;
	GROUP BY FunName ;
	HAVING COUNT(FunName)>1 ;
	ORDER BY FunName ;
	INTO CURSOR csrDups
	nDups = IIF(_Tally > 0, .T., .F.)
	USE IN csrDups
IF nDups = .T.
	=MESSAGEBOX("Cannot save, the Function Name is already used",0,"")
	nDups = .F.
	RETURN .F.
ENDIF
- Brian


VFP6 SP5, VFP8 SP1, VFP 9 SP 1 and Win XP SP 3 (unless otherwise specified)


www.wulfsden.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform