Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Repeated records
Message
 
 
To
01/08/2007 18:35:52
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01245292
Message ID:
01245342
Views:
20
>My table is new, and don´t have anything.
>
>and I consider 3 fields to determine if the record is repeated.
>
>Thanks
>CB

Hilmar provided you the code to check table for existing duplicates.

If you want to prevent insertion of duplicate records there are two approaches I can think of:

1. Create a candidate index on these 3 fields: (assuming all three of them are character):

index on field1 + field2 + field3 tag NoDups candidate

Then you would have to trap the error on the insert (or tableupdate).

Another way would be to check from the interface, e.g. assuming

lcField1, lcField2, lcField3 entered values, you may try
select myTable
locate for field1 == m.lcField1 and field2 == m.lcField2 and field3 = m.lcField3
if found()
  ** We can not insert these values, they are already in the table
endif
However, it may not work correctly in multi-user environment, so the first approach (candidate index) would be better.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform