Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best Practice to Avoid Duplicates
Message
 
 
À
28/08/2008 15:14:08
Steven Dyke
Safran Seats USA
Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01342767
Message ID:
01342775
Vues:
10
>I am using SPT to create a table for a report. Initially I find a list of assemblies that match a certain job number. This I scan through each assy breaking them down to detail parts. This may take several sub scans for assemblies of assemblies. Each of these details is written to a temporary table. Now my problem is some assemblies have common parts. What is the best way to make sure my insert sql statements only write one record per detail number?

You can always check your table before trying to INSERT, e.g.
select ID from myTable where exists (select 1 from myTable where myCommonPart = )
if _tally = 0 && We don't have this record yet
   insert
else
  update
endif
And in SQL Server
IF NOT EXISTS (select 1 from myTable where myPart = "Something")
    INSERT ...
Actually, may be you can create this as a Stored Procedure and do all the checks inside.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform