以下是引用hu9jj在2014-6-9 07:26:12的发言:
作业题
SELECT SUM(rg),SUM(zf) FROM fl INTO ARRAY xb
IF xb >0
USE flall
DELETE from flall where fyear =YEAR(bgtime) AND fperiod =MONTH(bgtime)
PACK
APPEND FROM fl
ELSE if
xb =0
=MESSAGEBOX('你没有更新数据,所以沿用之前数据!','重要提示',64,6000)
ENDIF
这是我自己 编写的代码,主要是判断有没有数据,如果没有录入数据,那么就将不会进行更新。下面是全部的代码:
*!*
CREATE DBF fl (;
*!*
cj
c(18),;
*!*
key
n(9,5),;
*!*
rg
n(9,5),;
*!*
zf
n(9,5),;
*!*
rgrate
n(9,5),;
*!*
zfrate
n(9,5))
SELECT distinc CAST(YEAR(bgtime)as n(4))fyear,CAST(month(bgtime)as n(2))fperiod,workshop,SUM(key)key,CAST(0as n(18,8))rg,CAST(0as n(18,8))zf,CAST(0 as n(18,8))jgf,CAST(0 as n(18,8))rgrate,CAST(0 as n(18,8))zfrate,CAST(0as n(18,8))jgfrate
FROM jqrwd GROUP BY 1,2,3 INTO TABLE fl
=MESSAGEBOX('请输入数据!','重要提示',64,6000)
BROWSE TIMEOUT 5
UPDATE FL SET RGRATE =IIF(KEY =0,0,RG/KEY),zfrate =IIF(key =0,0,zf/key),jgfrate=IIF(key=0,0,jgf/key)
CLOSE TABLES
SELECT SUM(rg),SUM(zf) FROM fl INTO ARRAY xb
IF xb >0
USE flall
DELETE from flall where fyear =YEAR(bgtime) AND fperiod =MONTH(bgtime)
PACK
APPEND FROM fl
ELSE if
xb =0
=MESSAGEBOX('你没有更新数据,所以沿用之前数据!','重要提示',64,6000)
ENDIF
SELECT workshop,key,rg,zf,jgf,rgrate,zfrate,jgfrate FROM flall WHERE fyear =YEAR(bgtime) AND fperiod =MONTH(bgtime) INTO CURSOR fla
COPY TO d:\fl TYPE CSV
现在的想法是如果需要一个参数就用一条select语句来整理,这样太复杂,也不方便,有木有比较快捷的方式让我能获取需要的数据进入变量。谢谢。
[
本帖最后由 hyz00001 于 2014-6-9 13:54 编辑 ]