>hello all
>
>i found some records that had the same primary key ID in the table.
>any one can tell me why it happened and how to prevent it?
>
>thx
It is best to use a "surrogate" primary key. This means that the user never sees or has control over them. The best solution that I have found is to use SYS(2015) as the primary key. I also add an additional string to it to virtually guarantee that there will never be duplicates generated DTOS(DATE())+SYS(2015). If you have a multi-site program you can also as an ID, a two or three character key should be sufficent for most any case, to the key.
ID+DTOS(DATE())+SYS(2015) will give you an ideal solution.
When you use this key to relate to other child records, you never have to worry about the time when the user needs to "change" a code. For example, if a user sets up a customer record for "All American Air" and they are allowed a 3 char code for the customer, they may use the customer code "AAA", your primary key (build in the background might be "0119980710_REWHFYFGKH" ).
When a new customer comes along, say "American Auto Association", and they decide that they need change the old code from "AAA" to "AA1" and the new one to "AA2". With out the surrogate key, you would have to search thru all the linked tables and change them. With the surrogate key, they are allowed to change the code to whatever they wish and all the related tables still point back to the correct record.
Hope this helps!
//:^)