Einzelnen Beitrag anzeigen

danten

Registriert seit: 19. Feb 2012
Ort: Czech Republic, Prag
126 Beiträge
 
Delphi 10.1 Berlin Architect
 
#1

Filtering two IBTable and insert or edit IBTable

  Alt 28. Feb 2014, 10:47
Datenbank: Firebird • Version: 2.3 • Zugriff über: 1
I need to recursively insert data from one table to another table by index (USERID =>> ID) common to both tables.
My function does not complete the operation.
Delphi-Quellcode:
function TFrm_main.Add_UserName:boolean;
var
  i:Integer;
begin
  ds_users.DataSet.First;
  for I := 0 to ds_users.DataSet.RecordCount -1 do
  begin
    Application.ProcessMessages;
    ds_attendant.DataSet.Filtered := False;
    ds_attendant.DataSet.Filter := 'USERID = '+QuotedStr(ds_users.DataSet.FieldByName('ID').Value);
    ds_attendant.DataSet.Filtered := True;
    Application.ProcessMessages;
  while not ds_attendant.DataSet.Eof do
  begin
  if (ds_attendant.DataSet.RecordCount > 0) then
  begin
    Application.ProcessMessages;
    ds_attendant.DataSet.Edit;
    ds_attendant.DataSet.FieldByName('NAME').Value := ds_users.DataSet.FieldByName('USERNAME').Value;
    ds_attendant.DataSet.Post;
    Application.ProcessMessages;
  end else
  begin
    ds_users.DataSet.Next;;
  end;
  end;
    ds_users.DataSet.Next;
  end;
  Result := True;
  ds_attendant.DataSet.Filtered := False;
end;
Daniel
  Mit Zitat antworten Zitat