请你翻译一段FOXPRO 程序,请尽量用SQL语句(急用!!请各位帮忙)(200分)

  • 主题发起人 主题发起人 宫雨
  • 开始时间 开始时间

宫雨

Unregistered / Unconfirmed
GUEST, unregistred user!
CLBMK 为 一个72 个字段的表
CREATE TABLE CLBMK (
BH VARCHAR(4),
BM VARCHAR(9),
BJBH VARCHAR(12),
MC VARCHAR(20),
XH VARCHAR(20),
DV VARCHAR(4),
SDJ DOUBLE PRECISION,
JDJ DOUBLE PRECISION,
DZ VARCHAR(1),
DZ1 VARCHAR(1),
YJL VARCHAR(1),
WZXZ VARCHAR(8),
SCCJ SMALLINT,
BAOJ1 DOUBLE PRECISION,
BAOJ2 DOUBLE PRECISION,
BAOJ3 DOUBLE PRECISION,
BCJ1 VARCHAR(20),
BCJ2 VARCHAR(20),
BCJ3 VARCHAR(20),
NCDJ DOUBLE PRECISION,
MAXDJ DOUBLE PRECISION,
MINDJ DOUBLE PRECISION,
DZL DOUBLE PRECISION,
ZZC DOUBLE PRECISION,
ZZQ DOUBLE PRECISION,
GCSL DOUBLE PRECISION,
GCJE DOUBLE PRECISION,
DCSL DOUBLE PRECISION,
DCJE DOUBLE PRECISION,
NCSL DOUBLE PRECISION,
NCJE DOUBLE PRECISION,
DQSL DOUBLE PRECISION,
DQJE DOUBLE PRECISION,
KW VARCHAR(11),
KB VARCHAR(10),
DAT_ DATE,
DJSJ DOUBLE PRECISION,
SRL1 DOUBLE PRECISION,
SRJ1 DOUBLE PRECISION,
SRL2 DOUBLE PRECISION,
SRJ2 DOUBLE PRECISION,
SRL3 DOUBLE PRECISION,
SRJ3 DOUBLE PRECISION,
SRL4 DOUBLE PRECISION,
SRJ4 DOUBLE PRECISION,
SRL5 DOUBLE PRECISION,
SRJ5 DOUBLE PRECISION,
SRL6 DOUBLE PRECISION,
SRJ6 DOUBLE PRECISION,
SRL7 DOUBLE PRECISION,
SRJ7 DOUBLE PRECISION,
SRL8 DOUBLE PRECISION,
SRJ8 DOUBLE PRECISION,
SRL DOUBLE PRECISION,
SRJ DOUBLE PRECISION,
SRD DOUBLE PRECISION,
FCL1 DOUBLE PRECISION,
FCJ1 DOUBLE PRECISION,
FCL2 DOUBLE PRECISION,
FCJ2 DOUBLE PRECISION,
FCL3 DOUBLE PRECISION,
FCJ3 DOUBLE PRECISION,
FCL4 DOUBLE PRECISION,
FCJ4 DOUBLE PRECISION,
FCL5 DOUBLE PRECISION,
FCJ5 DOUBLE PRECISION,
FCL6 DOUBLE PRECISION,
FCJ6 DOUBLE PRECISION,
FCL DOUBLE PRECISION,
FCJ DOUBLE PRECISION,
FCD DOUBLE PRECISION,
QMSL DOUBLE PRECISION,
QMJE DOUBLE PRECISION,
KGYH SMALLINT,
BJJ VARCHAR(2),
PD SMALLINT,
JDJ1 DOUBLE PRECISION,
JHYH SMALLINT,
SRJS DOUBLE PRECISION,
YZF DOUBLE PRECISION,
RGLFE DOUBLE PRECISION,
ZZSE DOUBLE PRECISION,
FKJ DOUBLE PRECISION,
FCJS DOUBLE PRECISION,
GLFE DOUBLE PRECISION,
ZJE DOUBLE PRECISION
)
clmxyk,clmx 为 42 个字段的表
CREATE TABLE CLMXYK (
BH VARCHAR(4),
BM VARCHAR(9),
MC VARCHAR(20),
XH VARCHAR(20),
DV VARCHAR(4),
JDJ DOUBLE PRECISION,
SDJ DOUBLE PRECISION,
SCCJ SMALLINT,
DWBH SMALLINT,
DZ VARCHAR(1),
DZ1 VARCHAR(1),
YJL VARCHAR(1),
BJBH VARCHAR(12),
CLYT VARCHAR(14),
SRL1 DOUBLE PRECISION,
SRJ1 DOUBLE PRECISION,
SRL2 DOUBLE PRECISION,
SRJ2 DOUBLE PRECISION,
SRL3 DOUBLE PRECISION,
SRJ3 DOUBLE PRECISION,
SRL4 DOUBLE PRECISION,
SRJ4 DOUBLE PRECISION,
SRL5 DOUBLE PRECISION,
SRJ5 DOUBLE PRECISION,
SRL6 DOUBLE PRECISION,
SRJ6 DOUBLE PRECISION,
SRL7 DOUBLE PRECISION,
SRJ7 DOUBLE PRECISION,
SRL8 DOUBLE PRECISION,
SRJ8 DOUBLE PRECISION,
SRL DOUBLE PRECISION,
SRJ DOUBLE PRECISION,
SRD DOUBLE PRECISION,
SRJS DOUBLE PRECISION,
YZF DOUBLE PRECISION,
RGLFL DOUBLE PRECISION,
RGLFE DOUBLE PRECISION,
FCL1 DOUBLE PRECISION,
FCJ1 DOUBLE PRECISION,
FCL2 DOUBLE PRECISION,
FCJ2 DOUBLE PRECISION,
FCL3 DOUBLE PRECISION,
FCJ3 DOUBLE PRECISION,
FCL4 DOUBLE PRECISION,
FCJ4 DOUBLE PRECISION,
FCL5 DOUBLE PRECISION,
FCJ5 DOUBLE PRECISION,
FCL6 DOUBLE PRECISION,
FCJ6 DOUBLE PRECISION,
FCL DOUBLE PRECISION,
FCJ DOUBLE PRECISION,
FCD DOUBLE PRECISION,
FCJS DOUBLE PRECISION,
GLFE DOUBLE PRECISION,
QCJE DOUBLE PRECISION,
QMSL DOUBLE PRECISION,
QMJE DOUBLE PRECISION,
DAT_ DATE,
SFBH VARCHAR(9),
CGYH SMALLINT,
KGYH SMALLINT,
YLD VARCHAR(10),
KDBH VARCHAR(12),
GLFL DOUBLE PRECISION,
ZJE DOUBLE PRECISION,
ZZSL DOUBLE PRECISION,
ZZSE DOUBLE PRECISION,
FKJ DOUBLE PRECISION,
GCBH VARCHAR(20),
CJMC VARCHAR(20),
WZXZ VARCHAR(10),
CGYM VARCHAR(8)
)
以下为源程序:
define window input from 8,15 to 17,65;
double;
shadow;
color scheme 5
activate window input
dimension bt(20)
*@ 5,8 say '不满两位补0'
*@ 3,8 say '汇总月份:' get mon;
pict "99";
size 1,2;
default ''
*read
use clmxyk
m.date=date

use clbmk
clea
@ 2,10 say '现 在 正 在 汇 总 '+str(month(m.date),2)+'月 数 据'
@ 4,14 say "..................."
copy to aa
use aa
@ 4,14 say "*"

appe from clmxyk
*dele for srj=0 .and. fcj=0
*pack
@ 4,col() say "*"
inde on bm to clin
@ 4,col() say "*"
total on bm to hzyb fields srl1,srl2,srl3,srl4,srl5,srl6,srl7,srl8,;
srj1,srj2,srj3,srj4,srj5,srj6,srj7,srj8,srd,srjs,yzf,zzse,rglfe,fcl1,fcl2,fcl3,fcl4,fcl5,;
fcj1,fcj2,fcj3,fcj4,fcj5,fcd,fcjs,glfe
@ 4,col() say "*"
use hzyb
repl all bh with substr(bm,1,2)
repl all srj with srj1+srj2+srj3+srj4+srj5+srj6+srj7+srj8
repl all srl with srl1+srl2+srl3+srl4+srl5+srl6+srl7+srl8
repl all fcj with fcj1+fcj2+fcj3+fcj4+fcj5
repl all fcl with fcl1+fcl2+fcl3+fcl4+fcl5
repl all fkj with srjs+zzse+rglfe+yzf,zje with glfe+fcjs
repl all qmsl with ncsl+srl-fcl,qmje with ncje+srj-fcj
@ 4,col() say "*"

inde on bh tag bh
total on bh to bk0
@ 4,col() say "*"
use bk0
inde on bh to aa
sele 2
use clhzdl
set rela to bh into bk0
for i=1 to 8
g=str(i,1)
repl all srj&g with bk0.srj&g
endfor
repl all srjs with bk0.srjs,yzf with bk0.yzf,zzse with bk0.zzse
repl all srd with bk0.srd,fcd with bk0.fcd,rglfe with bk0.rglfe
for i=1 to 5
g=str(i,1)
repl all fcj&g with bk0.fcj&g
endfor
repl all glfe with bk0.glfe,fcjs with bk0.fcjs
repl all srj1 with srj1+srj6
repl all srj6 with 0
repl all srj with srj1+srj2+srj3+srj4+srj5+srj6+srj7+srj8,;
fcj with fcj1+fcj2+fcj3+fcj4+fcj5
repl all fkj with srjs+yzf+rglfe+zzse,zje with glfe+fcjs
repl all ncje with bk0.ncje
repl all qmje with ncje+srj-fcj,date with date()
@ 4,col() say "*"

set rela off into bk0
close all data

&&& 汇总月库 &&&
use clmxyk
inde on bh to bh
total on bh to bk0 fields srl1,srl2,srl3,srl4,srl5,srl6,srl7,srl8,;
srj1,srj2,srj3,srj4,srj5,srj6,srj7,srj8,zzse,yzf,srjs,rglfe,srd,fcl1,fcl2,fcl3,fcl4,fcl5,;
fcj1,fcj2,fcj3,fcj4,fcj5,fcd,glfe,fcjs
@ 4,col() say "*"
use bk0
inde on bh to aa
sele 2
use clhzdly
set rela to bh into bk0
repl all srd with bk0.srd,fcd with bk0.fcd
for i=1 to 8
g=str(i,1)
repl all srj&g with bk0.srj&g
endfor
repl all srjs with bk0.srjs,yzf with bk0.yzf,zzse with bk0.zzse
repl all fcjs with bk0.fcjs,glfe with bk0.glfe,rglfe with bk0.rglfe
for i=1 to 5
g=str(i,1)
repl all fcj&g with bk0.fcj&g
endfor
repl all srj1 with srj1+srj6
repl all srj6 with 0

set rela off into bk0
sele 1
use clbmk order bh
total on bh to bk0 field qmje
use bk0
inde on bh to aa
sele 2
use clhzdly
set rela to bh into bk0
repl all srj1 with srj1+srj6
repl all srj6 with 0
repl all srj with srj1+srj2+srj3+srj4+srj5+srj6+srj7+srj8,;
fcj with fcj1+fcj2+fcj3+fcj4+fcj5
repl all fkj with zzse+srjs+rglfe+yzf,zje with glfe+fcjs
repl all qcje with bk0.qmje
repl all qmje with qcje+srj-fcj
@ 4,col() say "*"
set rela off into bk0
close all data

&&& 求月收/发项数 &&&
use clmxyk
copy to bb field bh,bm,srd,srj,fcd,fcj
use bb
inde on bm to clin
total on bm to aa
use aa
repl all for srj<>0 srd with 1
repl all for fcj<>0 fcd with 1
@ 4,col() say "*"
inde on bh to aa
total on bh to bk0
@ 4,col() say "*"
use bk0
inde on bh to aa
sele 2
use clhzdly
set rela to bh into bk0
repl all srd1 with bk0.srd,fcd1 with bk0.fcd
set rela off into bk0
close all data
@ 4,col() say "*"

&amp;&amp;&amp; 求年收/发项数 &amp;&amp;&amp;
use bb
appe from clmx
inde on bm to clin
total on bm to aa
use aa
repl all for srj<>0 srd with 1
repl all for fcj<>0 fcd with 1
@ 4,col() say "*"
inde on bh to aa
total on bh to bk0
@ 4,col() say "*"
use bk0
inde on bh to aa
sele 2
use clhzdl
set rela to bh into bk0
repl all srd1 with bk0.srd,fcd1 with bk0.fcd
set rela off into bk0
close all data
@ 4,col() say "*"

&amp;&amp;&amp; 求期初/期末项数 &amp;&amp;&amp;
use clbmk
copy to aa field bh,bm,dqsl,dqje,qmsl,qmje,ncsl,ncje
use aa
repl all bh with substr(bm,1,2),qmsl with 0,dqsl with 0,ncsl with 0
repl all for dqje<>0 dqsl with 1
repl all for qmje<>0 qmsl with 1
repl all for ncje<>0 ncsl with 1
@ 4,col() say "*"
inde on bh to aa
total on bh to bk0
@ 4,col() say "*"
use bk0
inde on bh to aa
sele 2
use clhzdly
set rela to bh into bk0
repl all qcd with bk0.qmsl,qmd with bk0.dqsl
use clhzdl
set rela to bh into bk0
repl all qcd with bk0.ncsl,qmd with bk0.dqsl
set rela off into bk0
@ 4,col() say "*"
close all data


&amp;&amp;&amp; 生成查询库 &amp;&amp;&amp;
use clhzdl
copy to clhz
copy to aa
use aa
repl all bb with '0'
inde on bb to aa
total on bb to cc
use cc
repl mc with "合 计",bh with ' '
use clhz
appe from cc

use clhzdly
copy to clhzy
copy to aa
use aa
repl all bb with '0'
inde on bb to aa
total on bb to cc
use cc
repl mc with "合 计",bh with ' '
use clhzy
appe from cc
?chr(7)
?chr(7)
clear
@ 4,15 say '汇 总 完 毕'
wait
use
clear windows
return
 
看上去不麻烦,自己太蓝,还是没有用过"带尔飞"
有什么问题提一下,或许能帮上忙.
 
你想干什么?
你的现在的数据库是什么?
你是想用delphi完成以上界面功能吗?
是想用query来完成对数据的操作处理吗?
说清楚点嘛!
 
w k! 自己的作业自己做! 有不懂的就来问.
 
这一段程序我只想翻译数据处理方面的,与界面无关,主要是我写出的程序
运行太慢(10分钟),数据库的记录上十万条。主要是请教各位有无较快的方
法,并无偷懒之意
 
呵呵, 哪一步慢把你的程序贴上来, 我们给你个优化:-)
 
这一段程序我只想翻译数据处理方面的,与界面无关,主要是我写出的程序
(10分钟),数据库的记录上十万条。主要是请教各位有无较快的方
法,并无偷懒之意
我用的是select * into temp from clbmk
select sum() from clmx
等等!!
 
repl all bh with substr(bm,1,2)
repl all srj with srj1+srj2+srj3+srj4+srj5+srj6+srj7+srj8
repl all srl with srl1+srl2+srl3+srl4+srl5+srl6+srl7+srl8
repl all fcj with fcj1+fcj2+fcj3+fcj4+fcj5
repl all fcl with fcl1+fcl2+fcl3+fcl4+fcl5
repl all fkj with srjs+zzse+rglfe+yzf,zje with glfe+fcjs
repl all qmsl with ncsl+srl-fcl,qmje with ncje+srj-fcj
把以上的语句改成一句:
repl all bh with substr(bm,1,2),srj with srj1+srj2+srj3+srj4+srj5+srj6+srj7+srj8, srl with srl1+srl2+srl3+srl4+srl5+srl6+srl7+srl8,fcj with fcj1+fcj2+fcj3+fcj4+fcj5,fcl with fcl1+fcl2+fcl3+fcl4+fcl5
,fkj with srjs+zzse+rglfe+yzf,zje with glfe+fcjs,qmsl with ncsl+srl-fcl,qmje with ncje+srj-fcj
 
多处重复的repl 都可以写成一句.
保证速度提高不少!
 
wgzhang: 他是想改成delphi的程序,不是想优化fox程序.
 
cAkk,估计不是吧?,不然界面这么办?
Foxpro也可以用SQL语句,但速度提高并不明显.
 
看看他的原话(摘抄如下),你为什么你仔细看一看就回答呢?
===============================================
这一段程序我只想翻译数据处理方面的,与界面无关,主要是我写出的程序
(10分钟),数据库的记录上十万条。主要是请教各位有无较快的方
法,并无偷懒之意
我用的是select * into temp from clbmk
select sum() from clmx
等等!!
 
我是想把他翻译成DELPHI 的程序
各位再帮帮忙!!
很快给分!!
 
其实问题很简单,把你的程序贴出来让大家瞧瞧,看看那句运行效率低。
我不信Delphi 的效率不及Fox
 
>>不信Delphi 的效率不及Fox?
难说。我的感觉刚好相反。
 
Foxpro操作foxpro自己的数据库,当然应该快一些.
 
如果不是优化Foxpro,全部改成Delphi的话,要知道用什么数据库,因为SQL语句会有不同.
赞同cytown,把代码贴出来.看Foxpro的太烦.
不要希望Delphi会提高速度,foxpro肯定比Delphi快.


 
多人接受答案了。
 
后退
顶部