求助高手:

zhangheng 2000-06-20 09:17:00
请教:怎样使下面的程序运行效率更高?本人开发一个程序,用Accesss数据库,有两个表是一对多个的关系,要把明细表的分组求和然后修改主表的数据。用如下方法(4000个记录运行8分钟)效率不理想,请高手指点:
while not table1.nof do
begin
table1.edit;
.......
table2fieldx.Asinteger := Table1fieldx.Asinteger;
tabl21.next;
end;
...全文
175 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Hibin 2000-06-22
  • 打赏
  • 举报
回复
Limu is good,however,you had best answer to the question with Chinese.
zhangheng 2000-06-21
  • 打赏
  • 举报
回复
用如下语程序提示错误:试图执行一个合计函数中不包括的定表达式'y'的查询

UPDATE table1, table2 SET table1.x = Sum(Table2.y)
WHERE table1.z=table2.z;

wyj1 2000-06-20
  • 打赏
  • 举报
回复
十分同意,最快的方法是用TQUERY语句.
AP 2000-06-20
  • 打赏
  • 举报
回复
分组求和清用 TQuery
然后 修改 Table 的值。
Limu 2000-06-20
  • 打赏
  • 举报
回复
I think you can use a TQuery Component instead of a TTable Component,and then you can use a UPDATE SQL statement to complete this task. Just like this:
TQuery.sql.add 'Update table2,table1 set table2.fieldX=sum(table1.fieldY) where table1.X=table2.X'
or similar statement.
halfdream 2000-06-20
  • 打赏
  • 举报
回复
是ACCESS ?
是ODBC 连接的吗? 这种情况下用TTABLE 就比较慢。

改用TQUERY 要好得多。
也可以试试用其它方式连接数据库。

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧