Okay, had some time left to try some more this is what I have so far:
I have 2 sdfdatasets filled from different csv files with different content.
However 1 dataset contains the same values as the other on, althought they are less in quantity.
Sdfdataset1 contains:
PNR;MTL;QTY; ... ;SLR;SRR; ... ;LGT; ... ;RLR;RRR, ...
75001;Alu;2; ... ;0.0;0.0; ... ;0; ... ;0.0;0.3; ...
75002;Alu;3; ... ;0.1;0.0; ... ;501; ... ;0.0;0.3; ...
75008;Alu;1; ... ;0.0;0.0; ... ;0; ... ;0.0;0.0; ...
40002;Alu;1; ... ;0.0;0.2; ... ;0; ... ;0.0;0.0; ...
40001;Alu;3; ... ;0.0;0.0; ... ;213; ... ;0.0;0.0; ...
40003;Alu;15; ... ;0.0;1.0; ... ;111; ... ;0.0;1.0; ...
45001;Alu;201; ... ;0.0;0.0; ... ;0; ... ;0.0;0.0; ...
...
Sdfdataset2 contains only this:
PNR1;LGT;ZGHL1;ZGHL2;ZGHR1;ZGHR2
40001;0;0.0;0.2;0.0;0.0
40002;0;0.0;0.0;0.0;0.0
40003;0;0.0;1.0;0.0;1.0
75008;0;0.0;0.0;0.0;0.0
So I want to update sdfdataset 2 with some values of sdfdataset1
PNR and PNR1 contain the same numbers (data) and will be used as a match.
so if PNR1 matches PNR, LGT, ZGHL1, ZGHL2, ZGHR1, ZGHR2 should be updated with the values from LGT, SLR, SRR, RLR, RRR
This is what I have so far but it stays on the first value of sdfdataset1 (it gets stuck in a loop)
F := SdfDataSet1.FieldByName('PNR');
G := SdfDataSet2.FieldByName('PNR1');
SdfDataSet2.DisableControls;
try
SdfDataSet2.First;
while not SdfDataSet2.EOF do
SdfDataSet1.First;
while not SdfDataSet1.EOF do
if VarSameValue(F.Value, G.Value) then
begin
//writeln('succes');
SdfDataSet2.Fields[x].AsInteger := SdfDataSet1.Fields[y].AsInteger;
SdfDataSet2.Fields[v].AsInteger := SdfDataSet1.Fields[w].AsInteger;
...
Exit;
end else begin
writeln('no succes');
SdfDataSet1.Next;
end;
SdfDataSet2.Next;
finally
SdfDataSet2.EnableControls;
end;
So what am I doing wrong here ?