MIS 系统. 做了一个测试. 主表5000 条记录, 子表45000条记录.
做一个子表记录的求和.发现在OPEN 的时候速度很慢.
有没有什么更好的办法.
代码
try
begin
Screen.Cursor := crHourGlass;
with dm.qyPub do
begin
Close;
SQL.Clear;
SQL.Add('select sum(amount) as totalt from outSub');
SQL.Add(' where mainno=' + QuotedStr(qyMain.FieldByName('billNo').AsString));
Open;
// qyMain.Refresh;
qyMain.Edit;
if FieldByName('Totalt').asFloat <> Null then
qyMain.FieldByName('amount').asFloat := FieldByName('totalt').asFloat;
if FieldByName('Totalt').AsFloat > 0 then
begin
qyMain.Edit;
qyMaincapitalMoney.AsString :=
pubu.GetCapitalMoney(FieldByName('Totalt').AsFloat);
qyMain.Post;
end;
Close;
end;
end;
finally
Screen.Cursor := crArrow;
end;