Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Borislav Borissov
  Where is Borislav Borissov?
 Sofia
 Bulgaria
 Borislav Borissov
 To: Rob Vleeschhouwer
  Where is Rob Vleeschhouwer?
 Leeuwarden
 Netherlands
 Rob Vleeschhouwer
 Tags
Subject: RE: Primary key
Thread ID: 104515 Message ID: 104534 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Thursday, August 17, 2006 12:36:46 PM         
   


> > > Hi,
> > >
> > > Is it possible to combine two fields for a primary key.
> > > In a orderform an articlenumber can be used twice, or more.
> > > So I will combine it with the field amount(m2). Making simple this two fields as primary key doesn't work.
> > >
> > > Rob
> >
> >
> > First I am not sure that if you set articlenumber + amount as PK will works either. What would happen if you have articlenumber + amount equal to something you added before but for different invoice/order?
>
> In the SQL only one order(client) is loaded on a time, based on cust_id
> Only when in one order there are two lines with same number and amount, there is a problem. But I can alllways write a valid in which, if this problem occurs, I increase the amount with 0.0001
> But, as I wrote before, making that two fields to primary key doesn't work.
> So I am afraid that I haven't done the right thing. But don't know what.
>
>



Then you must combine 3 fields not two:
client+articlenumber+amount

If you can't set them as PK you maybe already have duplicate values.
Run this in QA to see if you already have duplicate values:
SELECT Mes, God, MinZap, COUNT(1) AS Cnt
       FROM AllVar
       GROUP BY Mes, God, MinZap
       HAVING COUNT(1) > 1



Borislav Borissov



ENTIRE THREAD

Primary key Posted by Rob @ 8/17/2006 11:15:56 AM
RE: Primary key Posted by Bert Murillo @ 8/17/2006 11:27:43 AM
RE: Primary key Posted by Rob @ 8/17/2006 12:01:10 PM
RE: Primary key Posted by Bert Murillo @ 8/17/2006 12:45:03 PM
RE: Primary key Posted by Borislav Borissov @ 8/17/2006 11:36:23 AM
RE: Primary key Posted by Rob @ 8/17/2006 11:59:13 AM
RE: Primary key Posted by Borislav Borissov @ 8/17/2006 12:36:46 PM
RE: Primary key Posted by Marcia Akins @ 8/17/2006 12:29:32 PM
RE: Primary key Posted by Rob @ 8/17/2006 2:12:04 PM
RE: Primary key Posted by Borislav Borissov @ 8/17/2006 2:22:12 PM
RE: Primary key Posted by Koen Piller @ 8/17/2006 12:56:59 PM