没人用过这个吗?
一、ADO的Shape语句主要有两条:
1、Shape Append 命令
语法
SHAPE {parent-command} [[AS] parent-alias]
APPEND ({child-command} [AS] child-alias
RELATE parent-column TO child-column...) [[AS] chapter-alias] ...
特点:就是为主细SQL语句建立关联。没有出奇的性能。
2、Shape Compute 命令
语法
"SHAPE {child-command} [AS] child-alias
COMPUTE child-alias [ ,aggregate-command-field-list]
[BY grp-field-list]"
特点:是只列出细表的SQL语句,而主表是从细表中求得。有点意思,只是对查询速度无大的帮助。
而有时还会影响查询速度。只有在特殊时候才好使用。
二、测试:
经过测试以下两个语句所用时间都在4分左右,同以传统方法的主细写法没有太大的差别。
而值的一提的是用BDE只要几十秒钟就行了,如果是两层的BDE就更快了只要两秒钟。
语句一:
SHAPE {
Select comdcode,comname,sum(tamt) as JH,
(Select Sum(n.tamt) from t_salelist AS n INNER JOIN t_salelist AS m ON (n.orgcode = m.tcode) AND (n.orgno = m.tno) where m.comdcode=a.comdcode and n.whflag>='2' and n.saleflag>='2' and n.optype in ('批发','零售','退出','调出','盘亏','配出','移出')) as XS,
(Select Sum(n.Stock*n.tprice) from t_salelist n Where n.comdcode=a.comdcode and n.configdate=(Select distinct top 1 configdate from t_salelist Where itemdcode=n.itemdcode and whflag>='2' and saleflag>='2' order by configdate desc)) as KC
from t_salelist a
Where whflag>='2' and saleflag>='2' and optype in ('购入','调入','盘盈','退入','配入','移入')
Group by comdcode,comname
}
APPEND ({
Select comdcode,itemdcode,itemname,Speci,qtyunit,SUM(tamt) as JH,
(Select Sum(n.tamt) from t_salelist AS n INNER JOIN t_salelist AS m ON (n.orgcode = m.tcode) AND (n.orgno = m.tno) where m.comdcode=a.comdcode and m.itemdcode=a.itemdcode and n.optype in ('批发','零售','调出','盘亏','退出','配出','移出') and n.whflag>='2' and n.saleflag>='2') as XS,
(Select Max(stock*tprice) from t_salelist n Where n.comdcode=a.comdcode and n.itemdcode=a.itemdcode and n.configdate=(Select distinct top 1 configdate from t_salelist Where comdcode=n.comdcode and itemdcode=n.itemdcode and whflag>='2' and saleflag>='2' order by configdate desc)) as KC
from t_salelist a
Where whflag>='2' and saleflag>='2' and optype in ('购入','调入','盘盈','退入','配入','移入')
GROUP BY comdcode,itemdcode,itemname,Speci,qtyunit
} AS mx
RELATE comdcode TO comdcode)
语句一:
SHAPE {
Select a.comdcode,b.comname,a.itemdcode,a.itemname,a.speci,a.qtyunit,SUM(a.tamt) as JH,
(Select Sum(n.tamt) from t_salelist AS n INNER JOIN t_salelist AS m ON (n.orgcode = m.tcode) AND (n.orgno = m.tno) where m.comdcode=a.comdcode and m.itemdcode=a.itemdcode and n.optype in ('批发','零售','调出','盘亏','退出','配出','移出') and n.whflag>='2' and n.saleflag>='2') as XS,
(Select Max(stock*tprice) from t_salelist n Where n.comdcode=a.comdcode and n.itemdcode=a.itemdcode and n.configdate=(Select distinct top 1 configdate from t_salelist Where comdcode=n.comdcode and itemdcode=n.itemdcode and whflag>='2' order by configdate desc)) as KC
from t_custombusiness as b INNER JOIN t_salelist as a ON b.comdcode=a.comdcode
Where a.optype in ('购入','调入','盘盈','退入','配入','移入') and a.whflag>='2' and a.saleflag>='2'
GROUP BY a.comdcode,b.comname,a.itemdcode,a.itemname,a.speci,a.qtyunit
} AS mx
COMPUTE SUM(mx.JH),SUM(mx.XS),SUM(mx.KC),mx
by comdcode,comname
四、小结:
这样看看来Shape并不能提高SQL语句的执行效率。只是提供的一种的编程方便。而并不能从ADO内部大幅度的提高其性能。
凡世间万物有利就有弊,在Shape给我们提供了微不足到的帮助的同时,也给我们带来了一些莫明