Bonjour à toutes et à tous,

Dans mon programme, j'ai besoin d'alimenter une Table Client (interne) qui fait partie de ma base principal avec un autre table client (externe) faisant parti d'un autre logiciel.

- les champs entre les tables sont identique en terme de structure

Admettons que ma table client (interne) est remplie et que je souhaite lancer une intégration de mon autre table client (externe) sachant que si le code est identique je ne fait rien et je passe à l'enregistrement suivant.

Les Bases clients sont sous Access97
et je travail exclusivement avec ADO

J4ai plusieur possibilité :

1) je parcours ma table interne client et j'enregistre chaque code dans une variable (ici codeclient) séparé par une virgule puis je fais cette requette :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 
// ...
// requete qui prends que les clients différent de la base interne
// ...
      With ModuleDeDonneeSecondaire.ADOQueryClientBatigest Do
      Begin
        Try
          Try
            SQL.Clear;
            SQL.Add('Select * FROM Client');
            SQL.Add('Where Code = :xCodeClient');
            Parameters.ParamByName('xCodeClient').Value := CodeClient;
            Open;
//
// Insertion de chaque client nouveau dans ma base client interne
// 
            With ModuleDeDonneeSecondaire.ADOQuery do
            Begin
              Try
                Try
                  SQL.Clear;
                  SQL.Add('Insert into Client (CodeClt,NomClt,CiviliteClt,InterlocClt,AdresseClt,SuiteAdresseClt,CpClt,VilleClt,TelClt,FaxClt,PortableClt,EMailClt)');;
                  SQL.add('values (:C0,:C1,:C2,:C3,:C4,:C5,:C6,:C7,:C9,:C10,:C11,:C12)');
                  Parameters.ParamByName('C0').Value := ModuleDeDonneeSecondaire.ADOQueryClientBatigest.FieldByName('Code').AsString;
                  Parameters.ParamByName('C1').Value := ModuleDeDonneeSecondaire.ADOQueryClientBatigest.FieldByName('Nom').AsString;
                  Parameters.ParamByName('C2').Value := ModuleDeDonneeSecondaire.ADOQueryClientBatigest.FieldByName('Civilite').AsString;
                  Parameters.ParamByName('C3').Value := ModuleDeDonneeSecondaire.ADOQueryClientBatigest.FieldByName('Interloc').AsString;
                  Parameters.ParamByName('C4').Value := ModuleDeDonneeSecondaire.ADOQueryClientBatigest.FieldByName('Adr').AsString;
                  Parameters.ParamByName('C5').Value := ModuleDeDonneeSecondaire.ADOQueryClientBatigest.FieldByName('SuiteAdr').AsString;
                  Parameters.ParamByName('C6').Value := ModuleDeDonneeSecondaire.ADOQueryClientBatigest.FieldByName('CP').AsString;
                  Parameters.ParamByName('C7').Value := ModuleDeDonneeSecondaire.ADOQueryClientBatigest.FieldByName('Ville').AsString;
                  Parameters.ParamByName('C9').Value := ModuleDeDonneeSecondaire.ADOQueryClientBatigest.FieldByName('Tel').AsString;
                  Parameters.ParamByName('C10').Value := ModuleDeDonneeSecondaire.ADOQueryClientBatigest.FieldByName('Fax').AsString;
                  Parameters.ParamByName('C11').Value := ModuleDeDonneeSecondaire.ADOQueryClientBatigest.FieldByName('Portable').AsString;
                  Parameters.ParamByName('C12').Value := ModuleDeDonneeSecondaire.ADOQueryClientBatigest.FieldByName('EMail').AsString;
                  ExecSQL;
                Except
                  on E : Exception do
                  Begin
                    ShowMessage(E.ClassName+' erreur soulevée, avec le message : '+E.Message+#13+#10+
                    'Impossible d''intégrer un Client ' +#13+#10+
                    'Planning va fermer l''intégration.' +#13+#10+
                    'Si le problème persiste, merci de contacter votre revendeur');
                  end;
                end;
              Finally
                Close;
              end;
            end;
// ...
2) Je parcours la table externe, enregistrement par enregistrement et je regarde si le codeclient existe dans ma base client interne si oui je pass si non je continue

3) J'ai également pensé à faire un insert into complet de la base client (externe) sur la base client (interne) étant donné que "Code" est un champs primaire il ne peux pas créer 2 fois le même enregistrement, sauf que je tombe inévitablement sur une erreur de type doublon que je ne sais pas éviter (erase ?). Avec un autre RAD en faisant cette technique cela copiais que les clients elligiblent et ne me remontais pas l'erreur de doublons.

Ma question :
Existe-t-il une méthode plus simple ou/et plus rapide que cela ? ou comment integrer uniquement les codes différent d'une table à l'autre.