| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 524 人关注过本帖
标题:求助,怎样修改代码使程序取数据快一点
只看楼主 加入收藏
wxhapxl
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2011-7-29
结帖率:20%
收藏
已结贴  问题点数:6 回复次数:3 
求助,怎样修改代码使程序取数据快一点
下面是查询代码,
怎样修改下面的set filter to 语句查询时才能快一点
或者改那些代码执行时才能快
public l_tj1
select ck_cp_o     * 表1
set order to bm_bh
select ck_cp_op    * 表2
set order to bm_bh
select ck_cp_o
set relation to bm_bh into ck_cp_op  * 表2和表2通过bm_bh相关联
l_tj1 = 'ck_cp_o.ck_date>=ctod(l_ckd1)  and ck_cp_o.ck_date<=ctod(l_ckd2)'
if l_ckbh==''
  else
  l_tj1 =   l_tj1+' .AND. alltrim(ck_cp_o.bm_bh)=l_ckbh'
endi
if l_ckfs==''
  else
  l_tj1 =   l_tj1+' .AND. alltrim(ck_cp_o.ck_what)=l_ckfs'
endi
if l_ckbuy==''
  else
  l_tj1 =   l_tj1+' .AND. alltrim(ck_cp_o.dw_buy)=l_ckbuy'
endi
select ck_cp_o
set filter to &l_tj1
select ck_cp_o
set order to bm_bh
goto bottom
skip -5
THISFORM.grdck.RECORDSOURCETYPE = 1
THISFORM. grdck.RECORDSOURCE = "ck_cp_o"
THISFORM.grdck.COLUMNCOUNT = 11
THISFORM.grdck.FONTSIZE = 12
thisform.grdck.readonly = .t.
THISFORM.grdck.COLUMN1.HEADER1.CAPTION = "磅码单号"
THISFORM.grdck.COLUMN1.controlsource = "ck_cp_o.bm_bh"
THISFORM.grdck.COLUMN1.HEADER1.FONTSIZE = 12
THISFORM.grdck.COLUMN1.text1.FONTSIZE = 12
THISFORM.grdck.COLUMN1.WIDTH = 88
THISFORM.grdck.COLUMN1.HEADER1.FORECOLOR = RGB(0,0,255)

THISFORM.grdck.COLUMN2.HEADER1.CAPTION = "提货单位"
THISFORM.grdck.COLUMN2.controlsource = "ck_cp_o.dw_buy"
THISFORM.grdck.COLUMN2.HEADER1.FONTSIZE = 12
THISFORM.grdck.COLUMN2.WIDTH = 280
THISFORM.grdck.COLUMN2.text1.FONTSIZE = 12
THISFORM.grdck.COLUMN2.HEADER1.FORECOLOR = RGB(0,0,255)

THISFORM.grdck.COLUMN3.HEADER1.CAPTION = "提货日期"
THISFORM.grdck.COLUMN3.controlsource = "ck_cp_o.ck_date"
THISFORM.grdck.COLUMN3.HEADER1.FONTSIZE = 12
THISFORM.grdck.COLUMN3.WIDTH = 90
THISFORM.grdck.COLUMN3.HEADER1.FORECOLOR = RGB(0,0,255)
THISFORM.grdck.COLUMN3.text1.FONTSIZE = 12

THISFORM.grdck.COLUMN4.HEADER1.CAPTION = "出库方式"
THISFORM.grdck.COLUMN4.controlsource = "ck_cp_o.ck_what"
THISFORM.grdck.COLUMN4.HEADER1.FONTSIZE = 12
THISFORM.grdck.COLUMN4.WIDTH = 80
THISFORM.grdck.COLUMN4.HEADER1.FORECOLOR = RGB(0,0,255)
THISFORM.grdck.COLUMN4.text1.FONTSIZE = 12

THISFORM.grdck.COLUMN5.HEADER1.CAPTION = "生产单位"
THISFORM.grdck.COLUMN5.controlsource = "ck_cp_o.sc_dw"
THISFORM.grdck.COLUMN5.HEADER1.FONTSIZE = 12
THISFORM.grdck.COLUMN5.WIDTH = 80
THISFORM.grdck.COLUMN5.HEADER1.FORECOLOR = RGB(0,0,255)
THISFORM.grdck.COLUMN5.text1.FONTSIZE = 12

THISFORM.grdck.COLUMN6.HEADER1.CAPTION = "重量单位"
THISFORM.grdck.COLUMN6.controlsource = "ck_cp_o.dw"
THISFORM.grdck.COLUMN6.HEADER1.FONTSIZE = 12
THISFORM.grdck.COLUMN6.WIDTH = 70
THISFORM.grdck.COLUMN6.HEADER1.FORECOLOR = RGB(0,0,255)
THISFORM.grdck.COLUMN6.text1.FONTSIZE = 12

THISFORM.grdck.COLUMN7.HEADER1.CAPTION = "标(称)重"
THISFORM.grdck.COLUMN7.controlsource = "ck_cp_o.bc"
THISFORM.grdck.COLUMN7.HEADER1.FONTSIZE = 12
THISFORM.grdck.COLUMN7.WIDTH = 70
THISFORM.grdck.COLUMN7.HEADER1.FORECOLOR = RGB(0,0,255)
THISFORM.grdck.COLUMN7.text1.FONTSIZE = 12
THISFORM.grdck.COLUMN8.HEADER1.CAPTION = "跟随单位"
THISFORM.grdck.COLUMN8.controlsource = "ck_cp_o.wei_dw"
THISFORM.grdck.COLUMN8.HEADER1.FONTSIZE = 12
THISFORM.grdck.COLUMN8.WIDTH = 120
THISFORM.grdck.COLUMN8.HEADER1.FORECOLOR = RGB(0,0,255)
THISFORM.grdck.COLUMN8.text1.FONTSIZE = 12

THISFORM.grdck.COLUMN9.HEADER1.CAPTION = "是否结算"
THISFORM.grdck.COLUMN9.controlsource = "ck_cp_o.sfjs"
THISFORM.grdck.COLUMN9.HEADER1.FONTSIZE = 12
THISFORM.grdck.COLUMN9.WIDTH = 72
THISFORM.grdck.COLUMN9.HEADER1.FORECOLOR = RGB(0,0,255)
THISFORM.grdck.COLUMN9.text1.FONTSIZE = 12

THISFORM.grdck.COLUMN10.HEADER1.CAPTION = "合同号"
THISFORM.grdck.COLUMN10.controlsource = "ck_cp_o.ha_hth"
THISFORM.grdck.COLUMN10.HEADER1.FONTSIZE = 12
THISFORM.grdck.COLUMN10.WIDTH = 100
THISFORM.grdck.COLUMN10.HEADER1.FORECOLOR = RGB(0,0,255)
THISFORM.grdck.COLUMN10.text1.FONTSIZE = 12
THISFORM.grdck.COLUMN11.HEADER1.CAPTION = "备注"
THISFORM.grdck.COLUMN11.controlsource = "ck_cp_o.bz"
THISFORM.grdck.COLUMN11.HEADER1.FONTSIZE = 12
THISFORM.grdck.COLUMN11.WIDTH = 180
THISFORM.grdck.COLUMN11.HEADER1.FORECOLOR = RGB(0,0,255)
THISFORM.grdck.COLUMN11.text1.FONTSIZE = 12






select ck_cp_op
THISFORM.grdck_mx.RECORDSOURCETYPE = 1
THISFORM. grdck_mx.RECORDSOURCE = "ck_cp_op"
THISFORM.grdck_mx.COLUMNCOUNT = 6
THISFORM.grdck_mx.FONTSIZE = 12
thisform.grdck_mx.readonly = .t.
THISFORM.grdck_mx.COLUMN1.HEADER1.CAPTION = "   批 号"
THISFORM.grdck_mx.COLUMN1.controlsource = "ck_cp_op.ph"
THISFORM.grdck_mx.COLUMN1.HEADER1.FONTSIZE = 12
THISFORM.grdck_mx.COLUMN1.text1.FONTSIZE = 12
THISFORM.grdck_mx.COLUMN1.WIDTH = 100
THISFORM.grdck_mx.COLUMN1.HEADER1.FORECOLOR = RGB(0,0,255)

THISFORM.grdck_mx.COLUMN2.HEADER1.CAPTION = "   色 号"
THISFORM.grdck_mx.COLUMN2.controlsource = "ck_cp_op.sh"
THISFORM.grdck_mx.COLUMN2.HEADER1.FONTSIZE = 12
THISFORM.grdck_mx.COLUMN2.WIDTH = 108
THISFORM.grdck_mx.COLUMN2.text1.FONTSIZE = 12
THISFORM.grdck_mx.COLUMN2.HEADER1.FORECOLOR = RGB(0,0,255)

THISFORM.grdck_mx.COLUMN3.HEADER1.CAPTION = "               质"
THISFORM.grdck_mx.COLUMN3.controlsource = "ck_cp_op.ck_wp"
THISFORM.grdck_mx.COLUMN3.HEADER1.FONTSIZE = 12
THISFORM.grdck_mx.COLUMN3.WIDTH = 250
THISFORM.grdck_mx.COLUMN3.HEADER1.FORECOLOR = RGB(0,0,255)
THISFORM.grdck_mx.COLUMN3.text1.FONTSIZE = 12

THISFORM.grdck_mx.COLUMN4.HEADER1.CAPTION = "    货 位"
THISFORM.grdck_mx.COLUMN4.controlsource = "ck_cp_op.hw"
THISFORM.grdck_mx.COLUMN4.HEADER1.FONTSIZE = 12
THISFORM.grdck_mx.COLUMN4.WIDTH = 100
THISFORM.grdck_mx.COLUMN4.HEADER1.FORECOLOR = RGB(0,0,255)
THISFORM.grdck_mx.COLUMN4.text1.FONTSIZE = 12

THISFORM.grdck_mx.COLUMN5.HEADER1.CAPTION = "包号"
THISFORM.grdck_mx.COLUMN5.controlsource = "ck_cp_op.baoh"
THISFORM.grdck_mx.COLUMN5.HEADER1.FONTSIZE = 12
THISFORM.grdck_mx.COLUMN5.WIDTH = 50
THISFORM.grdck_mx.COLUMN5.HEADER1.FORECOLOR = RGB(0,0,255)
THISFORM.grdck_mx.COLUMN5.text1.FONTSIZE = 12

THISFORM.grdck_mx.COLUMN6.HEADER1.CAPTION = "   标 重"
THISFORM.grdck_mx.COLUMN6.controlsource = "ck_cp_op.bao_num"
THISFORM.grdck_mx.COLUMN6.HEADER1.FONTSIZE = 12
THISFORM.grdck_mx.COLUMN6.WIDTH = 100
THISFORM.grdck_mx.COLUMN6.HEADER1.FORECOLOR = RGB(0,0,255)
THISFORM.grdck_mx.COLUMN6.text1.FONTSIZE = 12
搜索更多相关主题的帖子: 查询 relation public 
2011-08-01 09:00
hu9jj
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:红土地
等 级:贵宾
威 望:400
帖 子:11857
专家分:43421
注 册:2006-5-13
收藏
得分:3 
其实楼主两个贴子的内容基本相同,完全没有必要重复发贴。浪费自己的时间,也浪费他人的时间。

活到老,学到老!http://www.(该域名已经被ISP盗卖了)E-mail:hu-jj@
2011-08-01 09:46
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:3 
1.日期型字段直接与日期型数据比较,不要再转换;
2.类似l_tj1 = l_tj1+' .AND. alltrim(ck_cp_o.bm_bh)=l_ckbh'中红色的变量,改用常量,里面加宏代换。

授人以渔,不授人以鱼。
2011-08-01 11:50
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
同样,日期型的比较也用常量,将日期值直接插在条件表达式中,用{^2011-08-01}这样的格式。例如:

l_ckd1 = "2011-08-01"
l_tj1 = "ck_cp_o.ck_date >= {^" + l_ckd1 + "}"
查询中的for &l_tj1

授人以渔,不授人以鱼。
2011-08-01 11:58
快速回复:求助,怎样修改代码使程序取数据快一点
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018020 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved