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
| WFDSql := TFDQuery.Create(nil) ;
WFDSql.Connection := FDDB ;
WFDSql.UpdateOptions.GeneratorName := 'EMPLOYES_BI' ;
WFDSql.UpdateOptions.KeyFields := 'ID_EMPLOYES' ;
FDQuery1.first ;
while not FDQuery1.Eof do
begin
if FDQuery2.Locate('ID_EMPLOYES', FDQuery1.FieldByName('ID_EMPLOYES').AsInteger,[]) then
begin
with WFDSql.Sql do
begin
clear ;
add('UPDATE EMPLOYES') ;
add('set PRESENT=:0, NUMBADGE=:1, NOM=:2, PRENOM=:3') ;
add('where ID_EMPLOYES=:4');
end;
WFDSql.ExecSQL('', [FDQuery1.FieldByName('PRESENT').AsString, FDQuery1.FieldByName('NUMBADGE').AsInteger,
FDQuery1.FieldByName('NOM').AsString, FDQuery1.FieldByName('PRENOM').AsString, FDQuery1.FieldByName('ID_EMPLOYES').AsInteger]) ;
end
else
begin
with WFDSql.Sql do
begin
clear ;
add('INSERT INTO EMPLOYES') ;
add('(PRESENT, NUMBADGE, NOM, PRENOM)') ;
add('values (:0,:1,:2,:3)') ;
end;
WFDSql.ExecSQL('', [FDQuery1.FieldByName('PRESENT').AsString, FDQuery1.FieldByName('NUMBADGE').AsInteger,
FDQuery1.FieldByName('NOM').AsString, FDQuery1.FieldByName('PRENOM').AsString]) ;
end ;
FDQuery1.next ;
end;
freeandnil(WFDSql) ; |
Partager