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;