Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checking for duplication
Message
De
22/06/1999 09:19:32
 
 
À
22/06/1999 03:19:27
Upendra Nayak
Cadsys Technologies
Mumbai, Inde
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00232354
Message ID:
00232444
Vues:
12
Hi Upendra,

The best way to deal with duplicate entries is to define a candidate key and check the result of TableUpdate(). In your case, I would define a candidate key on Upper(FName). Then, in your save method:
IF NOT TableUpdate()
   IF Seek(Upper(FName))
      MessageBox("Duplicate name")
   ELSE
      *-- Check for other reasons of failure here
   ENDIF
As for Tastrade, they are using a surrogate primary key (Customer_Id), which is unique. It's not uncommon to have more than one person with the same name, so the name cannot act as a good primary key field.

HTH

>Subject : Misbehaving application
>
>Dear Universalthread user's
>
>I am trying to create a simple data entry module which
>has a formset with toolbar to navigate (HOME,END,NEXT,PREVIOUS,SAVE,DELETE,UNDO,CLOSE).
>
>(Home,end,next,previous,save,delete,undo & close)
>works perfectly. But the problem start with key field
>validation which does not check for duplication. I
>have also reindex and recreated index file to check
>index file corruption.
>
>e.g.
>
>e.g i have a file (fname c 20) and i want it to be
>unique (i.e. no duplication entry).
>
>I have only one TEXTBOX on the form with
>controlsource = fmast.fname
>
>I have created index file on upper(fname)
>
>The valid function for the textbox is a shown below:
>**************
> if lastkey() = 27
> return .t.
> endif
>
> if empty(this.value)
> messagebox("File name cannot be empty.",32,"Alert !!")
> return .f.
> endif
>
> Select fmast
> xrecno = recno()
> this.controlsource = ""
>
> Select fmast
> set order to 2
> seek alltrim(upper(this.value))
> if found() .and. recno() # xrecno
> messagebox("This File name already exsist.",32,"Alert !!")
> goto xrecno
> this.controlsource = "fmast.fname"
> =tablerevert(.t.)
> this.refresh()
> return .f.
> endif
> goto xrecno
> this.controlsource = "fmast.fname"
> this.refresh()
> return .t.
>*********************
>
>I am also suprised to note that tasmania traders sample in VFP 6.0
>does not have any duplication check on it key fields.
>
>e.g
>1. In Customer module one can have two customer with same name.
>2. In product master one can have two product with same name.
>3. In Employee master one can have two employees with same name.
>
>Secondly there in no deletion option provided in the above sample.
>
>Is there any limitation on using following functions:
>
>cursorsetprop('Buffering',5,'fmast')
>tableupdate()
>tablerevert()
>
>Kindly let me know where i must have gone wrong.
>
>with regards
>(U.D. Nayak)
>Email : bilav@vsnl.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform