IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage Delphi Discussion :

Comment faire le Refresh lignes d'un query


Sujet :

Langage Delphi

  1. #1
    Membre du Club
    Inscrit en
    Juillet 2002
    Messages
    188
    Détails du profil
    Informations forums :
    Inscription : Juillet 2002
    Messages : 188
    Points : 47
    Points
    47
    Par défaut Comment faire le Refresh lignes d'un query
    Bonjour a tous,

    Voila j’ai un query qui marche bien SAUF…,
    je le lance comme ce ci

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    while not query.Eof do
    begin
      bla, bla...
      query.Next
    end;
    mais si la ligne suivante le champ est (vide, null) lui me reprend les infos de la ligne précédant

    j’ai essayé query.refresh, avant, après au début du NEXT, rien a faire

    qui peut m’aider !!!

    810mcu

  2. #2
    Membre émérite
    Homme Profil pro
    Directeur technique
    Inscrit en
    Mai 2008
    Messages
    2 401
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : Service public

    Informations forums :
    Inscription : Mai 2008
    Messages : 2 401
    Points : 2 310
    Points
    2 310
    Par défaut
    salut

    normalement ton code est bon ! combien d'enregistrements compte ton query ?
    ajoutes-en un query.first au début du code pour forcer le passage au 1er enregistrement et voyons ce qu'il donne.

    quel SGBD ? quel compo pour la connexion ?
    Bon courage ou Bonne Chance (selon le contexte)
    Mon blog sur WordPress

  3. #3
    Membre du Club
    Inscrit en
    Juillet 2002
    Messages
    188
    Détails du profil
    Informations forums :
    Inscription : Juillet 2002
    Messages : 188
    Points : 47
    Points
    47
    Par défaut
    Salut,

    Delphi6, Access2000, TADOquery

    oui j en utilise aussi, je complète

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    query.Open;
    query.First;
    while not query.Eof do
    begin
      query.Refresh;  //AU DEBUT, ne fait rien
      bla, bla
     
      query.Refresh
      query.Next;  // A LA FIN, ne fait rien
    end
    quand au nombre d enregistrement, le Max des Max +/-50 enregistrement

  4. #4
    Membre émérite
    Homme Profil pro
    Directeur technique
    Inscrit en
    Mai 2008
    Messages
    2 401
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : Service public

    Informations forums :
    Inscription : Mai 2008
    Messages : 2 401
    Points : 2 310
    Points
    2 310
    Par défaut
    un peu de nettoyage dans le code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    query.Open;
    ShowMessage(IntToStr(query.RecordCount)); // donne le nombre d'enrg retournés par la requête !
    //query.First; pas la peine
    while not query.Eof do
    begin
      // query.Refresh;  //AU DEBUT, ne fait rien
      //bla, bla
     
      //query.Refresh
      query.Next;  // A LA FIN, ne fait rien
    end
    si ta requête retourne un nombre > 1 alors le problème est dans la boucle est là faut voir ce que contient ton "bla bla" .
    Bon courage ou Bonne Chance (selon le contexte)
    Mon blog sur WordPress

  5. #5
    Membre du Club
    Inscrit en
    Juillet 2002
    Messages
    188
    Détails du profil
    Informations forums :
    Inscription : Juillet 2002
    Messages : 188
    Points : 47
    Points
    47
    Par défaut
    Citation Envoyé par 810mcu Voir le message
    Salut,

    Delphi6, Access2000, TADOquery

    oui j en utilise aussi, je complète

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    query.Open;
    query.First;
    while not query.Eof do
    begin
      query.Refresh;  //AU DEBUT, ne fait rien  
     
      table1.append
      table1.champ1.value := query.champ1.value;
      bla, bla
      table1.post;
     
      query.Refresh  // NE FAIT TJ rien
      query.Next;    // A LA FIN, ne fait rien
    end
    quand au nombre d enregistrement, le Max des Max +/-50 enregistrement

    OUI, le nombre de registre > 1.

  6. #6
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 091
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 091
    Points : 41 067
    Points
    41 067
    Billets dans le blog
    62
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    query.Open;
    while not query.Eof do
    begin
       ....... 
       query.Next; 
    end;
    //ceci , c'est le "refresh"
    Query.active:=False;  
    Query.Active:=True;
    maintenant , faire le "refresh" dans la boucle, c'est catégoriquement non ,
    sauf a vouloir une boucle infinie !!

    maintenant , si je reprend le problème de départ
    mais si la ligne suivante le champ est (vide, null) lui me reprend les infos de la ligne précédant
    et le texte du blabla
    table1.append
    table1.champ1.value := query.champ1.value;
    table1.post;
    j'en déduit deux choses
    - le planton doit venir du fait que tu tentes de mettre un champ null dans une table qui ne le permet pas (ce qui n'a pas été dit)
    - il y a le champ a la valeur null dans la table sur laquelle est faite la query
    ou encore , le blabla est encore incomplet et ma boule de cristal defaillante . UN PROBLEME BIEN POSE EST AU 3/4 RESOLU . , dire
    lui me reprend les infos de la ligne précédente
    c'est incompréhensible

    la façon de résoudre ce problème est simple soit modifier la query , en utilisant une clause Where
    SELECT CHAMP1 FROM TABLEREF
    WHERE CHAMP1 IS NOT NULL
    soit faire un test dans le blabla
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

  7. #7
    Membre du Club
    Inscrit en
    Juillet 2002
    Messages
    188
    Détails du profil
    Informations forums :
    Inscription : Juillet 2002
    Messages : 188
    Points : 47
    Points
    47
    Par défaut
    Salut, Bonjour a tous,
    On reprend du début SVP, est vous allez voir que c’est long… je voulais vous ménagez mais comme Sergio le dit (UN PROBLEME BIEN POSE EST AU 3/4 RESOLU).

    2/3 éclaircissements
    il s’agit d’un TRF de données de Table01 à Table02 en fonction des critères de recherche
    OUI Table02 accepte des nulle,
    OUI Table01 peut être nulle
    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
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
     
    // je donne le bon SQL au Query
      q_Search_gr_.Close;
      q_Search_gr_.SQL.Clear;
      q_Search_gr_.SQL.Add('SELECT ' +L_Nom_Table_Hist.Caption + '.* FROM ' +L_Nom_Table_Hist.Caption);
      q_Search_gr_.SQL.Add('where (ID_GRUME_H =:id_torro) and (IDX =:idc) and (N_ABAT =:Torro) and (ESSENCE =:gazolina) order by ID_HIST_GRUNE_H');
     
      q_procura_agenda_grume_2.Close;
      q_procura_agenda_grume_2.Open;
      q_procura_agenda_grume_2.First;
      while not q_procura_agenda_grume_2.Eof do
        begin
          tb_Destination_.Close;
          tb_Destination_.Open;
          tb_Destination_.First;
          //procura se o torro ja nao existe
          if tb_Destination_.Locate('ID_GRUME_H; IDX; N_ABAT; ESSENCE', VarArrayOf([q_procura_agenda_grume_2ID_GRUME_H.Value, q_procura_agenda_grume_2IDX.value, q_procura_agenda_grume_2N_ABAT.value, q_procura_agenda_grume_2ESSENCE.value]), []) then
            begin
              showMessage('grume existe ' +inttostr(q_procura_agenda_grume_2ID_GRUME_H.Value) +' ' +q_procura_agenda_grume_2IDX.Value +' ' +inttostr(q_procura_agenda_grume_2N_ABAT.Value) +' ' +q_procura_agenda_grume_2ESSENCE.value );
              tb_Destination_.Close;
              q_procura_agenda_grume_2.Next;
            end
          ELSE
            begin
              //busca do Historico do torro
              q_Search_gr_.Close;
              q_Search_gr_.Parameters[0].value := q_procura_agenda_grume_2ID_GRUME_H.Value;  //Nr. grume origine
              q_Search_gr_.Parameters[1].value := q_procura_agenda_grume_2IDX.Value;
              q_Search_gr_.Parameters[2].value := q_procura_agenda_grume_2N_ABAT.Value;
              q_Search_gr_.Parameters[3].value := q_procura_agenda_grume_2ESSENCE.Value;
              // ProgressBar1.Max := q_Search_gr_.RecordCount;
              //ShowMessage('TRF de HISTORIQUE ...');
              tb_Destination_Hist_.Close;
              tb_Destination_Hist_.Open;
     
              q_Search_gr_.Open;
              q_Search_gr_.First;
              //q_Search_gr_.Refresh;
              while not q_Search_gr_.Eof do
                begin
                  q_Search_gr_.Refresh;  //NE FAIT RIEN!!!
                  //enreg Antécédents ds l'Historique
                  tb_Destination_Hist_.Append;
                  tb_Destination_Hist_ID_GRUME_H.Value := q_Search_gr_ID_GRUME_H.Value;
                  tb_Destination_Hist_IDX.Value        := q_Search_gr_IDX.Value;
                  tb_Destination_Hist_N_ABAT.Value     := q_Search_gr_N_ABAT.Value;
                  tb_Destination_Hist_ESSENCE.Value    := q_Search_gr_ESSENCE.Value;
                  tb_Destination_Hist_LONG.Value     := q_Search_gr_LONG.Value;
                  tb_Destination_Hist_DIAM_AA.Value  := q_Search_gr_DIAM_AA.Value;
                  tb_Destination_Hist_DIAM_SA.Value  := q_Search_gr_DIAM_SA.Value;
                  tb_Destination_Hist_VOL_AA.Value   := q_Search_gr_VOL_AA.Value;
                  tb_Destination_Hist_VOL_SA.Value   := q_Search_gr_VOL_SA.Value;
                  tb_Destination_Hist_POIDS.Value    := q_Search_gr_POIDS.Value;
                  tb_Destination_Hist_PURGE.Value    := q_Search_gr_PURGE.Value;
                  tb_Destination_Hist_PURGE_NBR.Value:= q_Search_gr_PURGE_NBR.Value;
                  tb_Destination_Hist_REFACTION.Value:= q_Search_gr_REFACTION.Value;
                  tb_Destination_Hist_POSITION.Value := q_Search_gr_POSITION.Value;
                  tb_Destination_Hist_OBS.Value      := q_Search_gr_OBS.Value;
                  tb_Destination_Hist_D_ARR_NIOKI.Value:= q_Search_gr_D_ARR_NIOKI.Value;
                  tb_Destination_Hist_D_ARR_KIN.Value  := q_Search_gr_D_ARR_KIN.Value;
                  tb_Destination_Hist_DENSITE.Value    := q_Search_gr_DENSITE.Value;
                  tb_Destination_Hist_executeur.Value:= q_Search_gr_EXECUTEUR.Value;
                  tb_Destination_Hist_D_ENREG.Value  := q_Search_gr_D_ENREG.Value;  //date du Mvts
                  tb_Destination_Hist_DATA_BE.Value  := q_Search_gr_DATA_BE.Value;
                  tb_Destination_Hist_BE.Value       := q_Search_gr_BE.Value;
                  tb_Destination_Hist_TRANSP.Value   := q_Search_gr_TRANSP.Value;
                  tb_Destination_Hist_INFOS_TRANSP.Value:= q_Search_gr_INFOS_TRANSP.Value;
                  tb_Destination_Hist_CLASS.Value    := q_Search_gr_CLASS.Value;
                  tb_Destination_Hist_T.Value        := q_Search_gr_T.Value;
                  tb_Destination_Hist_.Post;
     
                  //q_Search_gr_.Delete;
                  showMessage('seguinte');
                  q_Search_gr_.Next;
                end;
     
              tb_GRUME_H_.Close;
              tb_GRUME_H_.Open;
              tb_GRUME_H_.Locate('ID_GRUME_H; IDX; N_ABAT; ESSENCE', VarArrayOf([q_procura_agenda_grume_2ID_GRUME_H.Value, q_procura_agenda_grume_2IDX.value, q_procura_agenda_grume_2N_ABAT.Value, q_procura_agenda_grume_2ESSENCE.value]), []);
     
              tb_Destination_.Close;
              tb_Destination_.Open;
              tb_Destination_.Append;
              tb_Destination_ID_GRUME_H.Value := tb_GRUME_H_ID_GRUME_H.Value;
              tb_Destination_IDX.Value        := tb_GRUME_H_IDX.Value;
              tb_Destination_N_RECEP.Value  := tb_GRUME_H_N_RECEP.Value;
              tb_Destination_N_ABAT.Value   := tb_GRUME_H_N_ABAT.Value;
              tb_Destination_L_ABAT.Value   := tb_GRUME_H_L_ABAT.Value;
              tb_Destination_D_ENREG.Value  := tb_GRUME_H_D_ENREG.Value;
     
              //Chg. 02.09.09 p/ inclure le N.Bord. Expedition tb_GRUME_H_B_SAVE.Value;
              //tb_Destination_D_SAVE.Value   := tb_GRUME_H_D_SAVE.Value;
              //tb_Destination_B_SAVE.Value   := tb_GRUME_H_B_SAVE.Value;
     
              tb_Destination_D_SAVE.Value   := tb_GRUME_H_D_SAVE.Value;
              tb_Destination_B_SAVE.Value   := tb_GRUME_H_B_SAVE.Value;
              tb_Destination_PERMIS.Value   := tb_GRUME_H_PERMIS.Value;
              tb_Destination_PROSPECT.Value := tb_GRUME_H_PROSPECT.Value;
              tb_Destination_PARCELLE.Value := tb_GRUME_H_PARCELLE.Value;
              tb_Destination_N_EXPORT.Value := tb_GRUME_H_N_EXPORT.Value;
              tb_Destination_ESSENCE.Value  := tb_GRUME_H_ESSENCE.Value;
              tb_Destination_CHANTIER.Value := tb_GRUME_H_CHANTIER.Value;
              tb_Destination_CORRESPOND.Value := tb_GRUME_H_CORRESPOND.Value;
              tb_Destination_DECOUPE.Value  := tb_GRUME_H_DECOUPE.Value;
              tb_Destination_Q.Value        := tb_GRUME_H_Q.Value;
              tb_Destination_LIC.Value      := tb_GRUME_H_LIC.Value;
              tb_Destination_PREVISION.Value := tb_GRUME_H_PREVISION.Value;
              tb_Destination_B_EXPED_KIN_MDI_D.Value := tb_GRUME_H_B_EXPED_KIN_MDI_D.Value;
              tb_Destination_B_EXPED_KIN_MDI.Value   := tb_GRUME_H_B_EXPED_KIN_MDI.Value;
              tb_Destination_TRANSPORTEUR.Value := tb_GRUME_H_TRANSPORTEUR.Value;
              tb_Destination_N_CONTENEUR.Value  := tb_GRUME_H_N_CONTENEUR.Value;
              tb_Destination_D_EXPORT.Value := tb_GRUME_H_D_EXPORT.Value;
              tb_Destination_N_BL.Value     := tb_GRUME_H_N_BL.Value;
              tb_Destination_BATEAU_EXP.Value  := tb_GRUME_H_BATEAU_EXP.Value;
              tb_Destination_DESTINATION.Value := tb_GRUME_H_DESTINATION.Value;
              tb_Destination_OBS.Value     :=  tb_GRUME_H_OBS.Value +' +GRUME_H_NIOKI_EXPED_ ';
              tb_Destination_ORIGINE_GR.Value := tb_GRUME_H_ORIGINE_GR.Value;
              tb_Destination_EXECUTEUR.Value  := tb_GRUME_H_EXECUTEUR.Value +L_nom_uti.Caption;
              tb_Destination_LONG.Value     := tb_GRUME_H_LONG.Value;
              tb_Destination_DIAM_AA.Value  := tb_GRUME_H_DIAM_AA.Value;
              tb_Destination_DIAM_AA1.Value := tb_GRUME_H_DIAM_AA1.Value;
              tb_Destination_DIAM_AA2.Value := tb_GRUME_H_DIAM_AA2.Value;
              tb_Destination_DIAM_AA3.Value := tb_GRUME_H_DIAM_AA3.Value;
              tb_Destination_DIAM_AA4.Value := tb_GRUME_H_DIAM_AA4.Value;
              tb_Destination_DIAM_SA.Value  := tb_GRUME_H_DIAM_SA.Value;
              tb_Destination_DIAM_SA1.Value := tb_GRUME_H_DIAM_SA1.Value;
              tb_Destination_DIAM_SA2.Value := tb_GRUME_H_DIAM_SA2.Value;
              tb_Destination_DIAM_SA3.Value := tb_GRUME_H_DIAM_SA3.Value;
              tb_Destination_DIAM_SA4.Value := tb_GRUME_H_DIAM_SA4.Value;
              tb_Destination_VOL_AA.Value   := tb_GRUME_H_VOL_AA.Value;
              tb_Destination_VOL_SA.Value   := tb_GRUME_H_VOL_SA.Value;
              tb_Destination_POIDS.Value    := tb_GRUME_H_POIDS.Value;
              tb_Destination_REFACTION.Value := tb_GRUME_H_REFACTION.Value;
              tb_Destination_POSICAO.Value  := tb_GRUME_H_POSICAO.Value;
              tb_Destination_CLASS.Value    := tb_GRUME_H_CLASS.Value;
              tb_Destination_.Post;
     
              tb_GRUME_H_.Delete;  //aki Delete pq moudou de tabela
              q_procura_agenda_grume_2.Next;  // para a trf
              // ProgressBar1.Position := 0;
            end;
        end;
    Merci a vous tous

    810mcu

  8. #8
    Membre du Club
    Inscrit en
    Juillet 2002
    Messages
    188
    Détails du profil
    Informations forums :
    Inscription : Juillet 2002
    Messages : 188
    Points : 47
    Points
    47
    Par défaut
    Salut,
    Faisons plus simple, je ne sais pas

    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
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
     
    // execution du TRF
      // je donne le bon sql, recherche de tous les registre suivant les critères
      q_Search_gr_.Close;
      q_Search_gr_.SQL.Clear;
      q_Search_gr_.SQL.Add('SELECT ' +L_Nom_Table_Hist.Caption + '.* FROM ' +L_Nom_Table_Hist.Caption);
      q_Search_gr_.SQL.Add('where (ID_GRUME_H =:id_torro) and (IDX =:idc) and (N_ABAT =:Torro) and (ESSENCE =:gazolina) order by ID_HIST_GRUNE_H');
      // la source
      q_procura_agenda_grume_2.Close;
      q_procura_agenda_grume_2.Open;
      q_procura_agenda_grume_2.First;
      while not q_procura_agenda_grume_2.Eof do
        begin
          tb_Destination_.Close;
          tb_Destination_.Open;
          tb_Destination_.First;
          //recherche si le registre existe déjà dans la table DESTINATION
          if tb_Destination_.Locate('ID_GRUME_H; IDX; N_ABAT; ESSENCE', VarArrayOf([q_procura_agenda_grume_2ID_GRUME_H.Value, q_procura_agenda_grume_2IDX.value, q_procura_agenda_grume_2N_ABAT.value, q_procura_agenda_grume_2ESSENCE.value]), []) then
            begin
              showMessage('grume existe ' +inttostr(q_procura_agenda_grume_2ID_GRUME_H.Value) +' ' +q_procura_agenda_grume_2IDX.Value +' ' +inttostr(q_procura_agenda_grume_2N_ABAT.Value) +' ' +q_procura_agenda_grume_2ESSENCE.value );
              tb_Destination_.Close;
              q_procura_agenda_grume_2.Next;
            end
          ELSE
            begin
              //DEBUT de la recherche les registre suivant les critères
              q_Search_gr_.Close;
    	//je donne les elements suivant (q_procura_agenda_grume_2ID)
              q_Search_gr_.Parameters[0].value := q_procura_agenda_grume_2ID_GRUME_H.Value;  
              q_Search_gr_.Parameters[1].value := q_procura_agenda_grume_2IDX.Value;
              q_Search_gr_.Parameters[2].value := q_procura_agenda_grume_2N_ABAT.Value;
              q_Search_gr_.Parameters[3].value := q_procura_agenda_grume_2ESSENCE.Value;
              // ProgressBar1.Max := q_Search_gr_.RecordCount;
              //ShowMessage('TRF de HISTORIQUE ...');
              tb_Destination_Hist_.Close;
              tb_Destination_Hist_.Open;
    	//après recupération
              q_Search_gr_.Open;
              q_Search_gr_.First;
              //q_Search_gr_.Refresh;
              while not q_Search_gr_.Eof do
                begin
                  q_Search_gr_.Refresh;
                  //enreg Antécédents ds l'Historique
                  tb_Destination_Hist_.Append;
                  tb_Destination_Hist_ID_GRUME_H.Value := q_Search_gr_ID_GRUME_H.Value;
                  tb_Destination_Hist_IDX.Value        := q_Search_gr_IDX.Value;
                  tb_Destination_Hist_N_ABAT.Value     := q_Search_gr_N_ABAT.Value;
                  tb_Destination_Hist_ESSENCE.Value    := q_Search_gr_ESSENCE.Value;
                  tb_Destination_Hist_LONG.Value     := q_Search_gr_LONG.Value;
                  tb_Destination_Hist_DIAM_AA.Value  := q_Search_gr_DIAM_AA.Value;
                  tb_Destination_Hist_DIAM_SA.Value  := q_Search_gr_DIAM_SA.Value;
                  tb_Destination_Hist_VOL_AA.Value   := q_Search_gr_VOL_AA.Value;
                  tb_Destination_Hist_VOL_SA.Value   := q_Search_gr_VOL_SA.Value;
                  tb_Destination_Hist_POIDS.Value    := q_Search_gr_POIDS.Value;
                  tb_Destination_Hist_PURGE.Value    := q_Search_gr_PURGE.Value;
                  tb_Destination_Hist_PURGE_NBR.Value:= q_Search_gr_PURGE_NBR.Value;
                  tb_Destination_Hist_REFACTION.Value:= q_Search_gr_REFACTION.Value;
                  tb_Destination_Hist_POSITION.Value := q_Search_gr_POSITION.Value;
                  tb_Destination_Hist_OBS.Value      := q_Search_gr_OBS.Value;
                  tb_Destination_Hist_D_ARR_NIOKI.Value:= q_Search_gr_D_ARR_NIOKI.Value;
                  tb_Destination_Hist_D_ARR_KIN.Value  := q_Search_gr_D_ARR_KIN.Value;
                  tb_Destination_Hist_DENSITE.Value    := q_Search_gr_DENSITE.Value;
                  tb_Destination_Hist_executeur.Value:= q_Search_gr_EXECUTEUR.Value;
                  tb_Destination_Hist_D_ENREG.Value  := q_Search_gr_D_ENREG.Value;  //date du Mvts
                  tb_Destination_Hist_DATA_BE.Value  := q_Search_gr_DATA_BE.Value;
                  tb_Destination_Hist_BE.Value       := q_Search_gr_BE.Value;
                  tb_Destination_Hist_TRANSP.Value   := q_Search_gr_TRANSP.Value;
                  tb_Destination_Hist_INFOS_TRANSP.Value:= q_Search_gr_INFOS_TRANSP.Value;
                  tb_Destination_Hist_CLASS.Value    := q_Search_gr_CLASS.Value;
                  tb_Destination_Hist_T.Value        := q_Search_gr_T.Value;
                  tb_Destination_Hist_.Post;
     
                  //q_Search_gr_.Delete;
                  //showMessage('seguinte');
                  q_Search_gr_.Next;
                end;
    que pouvez-vous me dire, svp...
    Merci

  9. #9
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 091
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 091
    Points : 41 067
    Points
    41 067
    Billets dans le blog
    62
    Par défaut
    Une histoire de Grumes , cela me rappelle des choses

    simplifions

    première chose :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
      q_procura_agenda_grume_2.Open;
     // q_procura_agenda_grume_2.First;    inutile
    ensuite ceci me semble tres lourd
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
      while not q_procura_agenda_grume_2.Eof do
        begin
          tb_Destination_.Close;
          tb_Destination_.Open;
          tb_Destination_.First;
          //recherche si le registre existe déjà dans la table DESTINATION
          if tb_Destination_.Locate('ID_GRUME_H; IDX; N_ABAT; ESSENCE', VarArrayOf([q_procura_agenda_grume_2ID_GRUME_H.Value, q_procura_agenda_grume_2IDX.value, q_procura_agenda_grume_2N_ABAT.value, q_procura_agenda_grume_2ESSENCE.value]), []) then
            begin
              showMessage('grume existe ' +inttostr(q_procura_agenda_grume_2ID_GRUME_H.Value) +' ' +q_procura_agenda_grume_2IDX.Value +' ' +inttostr(q_procura_agenda_grume_2N_ABAT.Value) +' ' +q_procura_agenda_grume_2ESSENCE.value );
              tb_Destination_.Close;
              q_procura_agenda_grume_2.Next;
            end
    L'ouverture de la table tb_Destination_ se fait a chaque fois !!!!! ne serait-il pas judicieux de la faire avant la boucle ?

    ne serait-il encore pas moins judicieux d'éviter de l'ouvrir , et donc de faire un locate , en faisant un join avec une autre query ?

    en tout cas ce que je peux déjà déduire , c'est que ce traitement doit ramer un max !! , il serait judicieux de revoir l'algorithme

    si j'ai bien lu (post de 9h58 le suivant semble incomplet)

    INITIALISATION DE LA QUERY DE RECHERCHE (ANTECEDENTS ?)
    OUVERTURE DE LA TABLE
    POUR CHAQUE ENREGISTREMENT DE LA TABLE
    - VERIFIER SI IL Y A UN HISTORIQUE
    - SI OUI AFFICHER
    - SI NON EN CREER UN (VOIR CREATION HISTORIQUE)
    FERMETURE DE LA TABLE
    //CREATION HISTORIQUE
    ENREGISTRER LES ANTECEDENTS
    AJOUTER L'ENREGISTREMENT
    Est-ce cela l'objectif ?
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

  10. #10
    Membre du Club
    Inscrit en
    Juillet 2002
    Messages
    188
    Détails du profil
    Informations forums :
    Inscription : Juillet 2002
    Messages : 188
    Points : 47
    Points
    47
    Par défaut
    Salut, et merci de tes conseils Sergio, c’est vrai que ça rame oui,
    et donc de faire un locate , en faisant un join avec une autre query ?
    OUI tu peux m’expliquer comment (join avec une autre query ?)? Merci

    Oui, ça se rapproche un max comme tu l’as décris et si ça peut aider voila comme je l’est projeter
    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
     
    Tb_Source
    Tb_Source_Hist
     
    Tb_Destination
    Tb_Destination_Hist
     
    Query_Pré-selection des données
    POUR CHAQUE ENREGISTREMENT DE LA TABLE
    Verifier, si grume existe dans Tb_Destination
     -Si OUI,
       Query_Pré-selection  suivant
     
     -Si NON,
       -Query_Collecte Table_Source_Hist (avec critères de Query_Pré-selection)
        ENREGISTRER LES ANTECEDENTS -Tb_Destination_Hist reçoit données Query_Collecte
     
      -Tb_Destination recoit (Query_Pré-selection)

  11. #11
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 091
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 091
    Points : 41 067
    Points
    41 067
    Billets dans le blog
    62
    Par défaut
    Content de voir que j'ai a peu près compris le problème

    OUI tu peux m’expliquer comment (join avec une autre query ?)? Merci
    il me faudrait une description succincte des tables (source et destination , clé primaire pour liaison), mais voilà , à peu près le principe
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    // la query sur la table source
    SELECT S.*,D.ID_GRUM AS EXISTE FROM SOURCE S LEFT JOIN DESTINATION D
    ON S.ID_GRUM =D.ID_GRUM  and S.IDX =D.IDX and S.N_ABAT =D.N_ABAT and S.ESSENCE =D.ESSENCE 
    WHERE .....
     
    // pour le test d'existence (ou plutôt de non existence)
    if query.fieldbyname('EXISTE').isnull then 
     begin
        // n'existe pas
     end
     else begin
        // existe 
     end;
    de plus , si il n'y a rien a faire lorsque l'enregistrement existe dans DESTINATION , ajouter dans la clause WHERE la clause EXISTE IS NOT NULL évitera même d'avoir a faire le test

    Ensuite pour la copie des enregistrements , plutôt que faire un bloc
    [edit ...... post] pourquoi ne pas utiliser un SQL du genre

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    INSERT INTO DEST (<liste champ>) SELECT <liste champ> FROM SOURCE WHERE
    Avec un petit execsql

    surtout que l'ensemble semble être une bête copie champ à champ
    le plus gros du boulot alors n'est plus de programmer mais de contrôler le SQL

    si j'ai bien compris l'objectif 3 Query suffirait
    1- la première sélection des enregistrements source avec liaison sur destination
    2- insert dans destination de l'enregistrement source
    3- insert dans historique destination des historiques sources
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

  12. #12
    Membre du Club
    Inscrit en
    Juillet 2002
    Messages
    188
    Détails du profil
    Informations forums :
    Inscription : Juillet 2002
    Messages : 188
    Points : 47
    Points
    47
    Par défaut
    Salut Sergio,
    Oui, oui tu as bien ciblé le problème.

    Oui tout à fait, 3 Query suffise, surtout si j’arrive à gagner du temps oh super.
    Et oui en gros c’est le TRF des Tables SOURCE vers DESTINATION, est elles sont identiques.

    L’objectif et comme tu le décrit

  13. #13
    Membre du Club
    Inscrit en
    Juillet 2002
    Messages
    188
    Détails du profil
    Informations forums :
    Inscription : Juillet 2002
    Messages : 188
    Points : 47
    Points
    47
    Par défaut
    Sergio, ou âme charitable

    Comme tu l’as décrit
    // la query sur la table source
    SELECT S.*,D.ID_GRUM AS EXISTE FROM SOURCE S LEFT JOIN DESTINATION D
    ON S.ID_GRUM =D.ID_GRUM and S.IDX =D.IDX and S.N_ABAT =D.N_ABAT and S.ESSENCE =D.ESSENCE
    WHERE .....
    Ds le cas de 2 Bases avec même NOM_TABLE, commet indiquer dans le query

    Select Base1.NOM_TABLE.*, Base2.NOM_TABLE.ID_GRUM AS EXISTE FROM DOURCE S LEFT JOIN DESTINATION D
    A savoir que dans la FORM
    Base1.NOM_TABLE compo une TADOTable

    Base2.NOM_TABLE compo autre TADOTable

    Merci

  14. #14
    Membre du Club
    Inscrit en
    Juillet 2002
    Messages
    188
    Détails du profil
    Informations forums :
    Inscription : Juillet 2002
    Messages : 188
    Points : 47
    Points
    47
    Par défaut
    A savoir que dans la FORM

    Base1.NOM_TABLE compo une TADOTable

    Base2.NOM_TABLE compo autre TADOTable

  15. #15
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 091
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 091
    Points : 41 067
    Points
    41 067
    Billets dans le blog
    62
    Par défaut
    Ah , je craignais ce genre de problème !! mais tu ne l'avais pas indiqué , petit cachotier

    je ne suis pas fana de ADO , (j'adorais BDE pour ce genre de pépin)
    est-ce que ADO accepte le genre de syntaxe "base:table" ? j'avoue ne pas le savoir
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

  16. #16
    Membre du Club
    Inscrit en
    Juillet 2002
    Messages
    188
    Détails du profil
    Informations forums :
    Inscription : Juillet 2002
    Messages : 188
    Points : 47
    Points
    47
    Par défaut
    Sorry Sergio, de ne pas avoir indiquer, mais c’est que tu mas donner d’autres idées des bonnes,
    Soucis de gagner du temps dans les tranferts

    Oui, à différent niveau de TRF d’infos dont 1 se fait de BASE1 à BASE2,
    Les autres de tables a tables,
    Si
    est-ce que ADO accepte le genre de syntaxe "base:table" ? j'avoue ne pas le savoir
    je ne sais pas te dire,
    Je fait ma connexion a l’ADO comme suit
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    tb_Origem_.ConnectionString := 'Provider=MSDASQL;Password=xc_sode_FoR;Persist Security Info=True;User ID=Administrador;Extended Properties="DBQ=' +E_Source_Ch.Text +';DefaultDir=' +E_Source_Ch.Text +';Driver={Driver do Microsoft Access (*.mdb)};DriverId=25;FIL=MS Access;FILEDSN=' +E_Source_Ch.Text +'.dsn;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;PWD=sode_FoR;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;"';
    via 1 Bouton que se sais parcourrir est localiser la Base2
    la Base1 et celle qui est utilisé

    Autre question, pour faire Actualisation des infos d 1 Table, registres existent
    UPDATE TABLE ….C’est bon ??? ou tu as autre idée ???

    Merci gards.

  17. #17
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 091
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 091
    Points : 41 067
    Points
    41 067
    Billets dans le blog
    62
    Par défaut
    après recherches , il semble que cela soit possible avec ADO ,(ce qui me réconcilie un peu avec ADO )
    il faut que les deux alias soit créés
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    SELECT Employee.CustNo, Clients.OrderNo FROM ":AliasBase2:Employee" JOIN ":AliasBase1:Clients" ON (Customer.CustNo = Orders.CustNo) WHERE .....
    donc , si on applique à ton problème

    tb_Origem_ = Base1
    tb_dest_ =Base2
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Select S.*, D.NOM_TABLE.ID_GRUM AS EXISTE FROM ":Base1:NOM_TABLE" S LEFT JOIN ":BASE2:NOM_TABLE" D  ON .....
    je te laisse le soin de faire les tests , a toi de confirmer que cela fonctionne
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

  18. #18
    Membre du Club
    Inscrit en
    Juillet 2002
    Messages
    188
    Détails du profil
    Informations forums :
    Inscription : Juillet 2002
    Messages : 188
    Points : 47
    Points
    47
    Par défaut
    Salut Sergio,
    J'ai reussi a faire quelque chose,
    mais j’ai un mot de passe dans la base, comment écrire la syntaxe pour Mot de Passe

    J’ai essayer ça, mais sans succès, tu peux m'aider svp,

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    'D:\Programs_D6\Madeiras\Sodefor\Nioki\2010\Recu\Sdf\05\18\zip\Mad.mdb;Password=MOT_PASSE'
    ou encore
    'D:\Programs_D6\Madeiras\Sodefor\Nioki\2010\Recu\Sdf\05\18\zip\Mad.mdb,Password=MOT_PASSE'
    J’ai aussi testé ça, pour la query, mais sans succès,

    J’ai en retour le Msg (Erreur de syntaxe dans la clause Form)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    Select S.*, D.GRUME_H_NIOKI_.ID AS EXISTE 
     
    FROM GRUME_H_NIOKI_ in 'D:\Programs_D6\Madeiras\Sodefor\Nioki\2010\Recu\Sdf\05\18\zip\Mad.mdb' S 
     
    LEFT JOIN 'GRUME_H_NIOKI_' D  
     
    ON 
    S.PERMIS =D.PERMIS and S.IDX =D.IDX and S.N_ABAT =D.N_ABAT and S.ESSENCE =D.ESSENCE
    Là je galère...Merci

  19. #19
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 091
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 091
    Points : 41 067
    Points
    41 067
    Billets dans le blog
    62
    Par défaut
    j'envoie les rames

    si tu as bien lu mon dernier post , j'ai indiqué qu'il te fallait 2 alias
    c'est à dire 2 ADOConnections donc le mot de passe serait dans l'ADOConnection je pense .
    De plus ce n'est absolument pas la syntaxe que je t'ai indiqué !!


    Quant aux ADOQuerys , je ne sais absolument pas s'il faut ou non leur indiquer de connexion préférentielle
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

  20. #20
    Membre du Club
    Inscrit en
    Juillet 2002
    Messages
    188
    Détails du profil
    Informations forums :
    Inscription : Juillet 2002
    Messages : 188
    Points : 47
    Points
    47
    Par défaut
    Salut Sergio,
    Quand à la syntaxe ça doit être ça puisque j’ai 1 réponse du query !!! ne sais pas

    ADOConnection2 Externe(la BASE externe a l'appli.)
    tb_Origem_
    TableName = GRUME_H_NIOKI_
    CHAMPS = PERMIs, IDX, N_ABAT, ESSENCE

    ADOConnection1 (BASE de l'Appli.)
    tb_Destino_
    TableName = GRUME_H_NIOKI_
    CHAMPS = PERMIs, IDX, N_ABAT, ESSENCE

    sur base de ceci
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    Select S.*, D.NOM_TABLE.ID_GRUM AS EXISTE 
    FROM ":Base1:NOM_TABLE" S 
    LEFT JOIN ":BASE2:NOM_TABLE" D  
    ON .....
    j'ai fait
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    Select S.*, D.GRUME_H_NIOKI_.N_ABAT AS EXISTE 
    FROM ':ADOConnection2:GRUME_H_NIOKI_' S
    JOIN  GRUME_H_NIOKI_ D
    ON S.PERMIS =D.PERMIS and S.IDX =D.IDX 
    and S.N_ABAT =D.N_ABAT and S.ESSENCE =D.ESSENCE
    WHERE EXISTE IS NOT NULL
    ou encore
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    Select S.*, D.GRUME_H_NIOKI_.N_ABAT AS EXISTE 
    FROM ':ADOConnection2:GRUME_H_NIOKI_' S
    JOIN  ":ADOConnection2:GRUME_H_NIOKI_" D
    ON S.PERMIS =D.PERMIS and S.IDX =D.IDX 
    and S.N_ABAT =D.N_ABAT and S.ESSENCE =D.ESSENCE
    WHERE EXISTE IS NOT NULL
    sans succes....

    MAIS, J’obtiens Msg,
    Erreur de syntaxe dans la requête. La clause de la requête est incomplète


    là j'ai besoin d'aide SVP... ou trouver de la doc. p/ ça,
    merci

Discussions similaires

  1. Comment faire un refresh dans les pages web (.uix)
    Par isicien dans le forum JDeveloper
    Réponses: 2
    Dernier message: 13/02/2009, 22h10
  2. Réponses: 3
    Dernier message: 20/05/2006, 01h44
  3. Comment faire un retour ligne entre des " ??
    Par DrTank dans le forum Balisage (X)HTML et validation W3C
    Réponses: 8
    Dernier message: 09/05/2005, 09h35
  4. Comment faire pour modifier une ligne dans une DBGrid?
    Par Nico62 dans le forum C++Builder
    Réponses: 6
    Dernier message: 29/03/2005, 12h24
  5. Comment faire un retour a la ligne dans un tableaux Word
    Par alexmorel dans le forum API, COM et SDKs
    Réponses: 2
    Dernier message: 17/06/2004, 09h31

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo