- 论坛徽章:
- 0
|
请教,
如何将一个表中的数据,每50条记录导出生成一个文件,
每个文件的文件名定义为
"GDCL" clipped,起始条编号,终止条编号,".csv"
表中有一字段tm_count为记录编号,
以下是我的处理程序,在表记录小于50条时,可以正常导出,但是如果大于50条,文件能生成,但是,每个文件(包括第一个文件)都是空的,没有记录,各位帮忙看看错在哪儿,谢谢了!!
MAIN
..........
FOR s = 1 to i
LET ss = s * 50 - 49 //起始记录编号
LET se = s * 50 //终止记录编号
DISPLAY "数据范围", ss, "至", se at 16,13
LET lv_qs = "GDCL" clipped, ss CLIPPED,se CLIPPED,".csv" //生成的文件名
START REPORT rep_gdcl TO lv_qs
DECLARE rep_cur CURSOR FOR
SELECT * FROM tmp_gdcl
where tm_count >;= ss and tm_count <=se
FOREACH rep_cur INTO l_gdcl.*
OUTPUT TO REPORT rep_gdcl(l_gdcl.*)
END FOREACH
CLOSE rep_cur
FREE rep_cur
FINISH REPORT rep_gdcl
end for
..........
END MAIN
REPORT rep_gdcl(l_gdcl)
DEFINE l_gdcl RECORD
tm_count int,
t_1 date,
t_2 date,
t_3 char(20),
t_4 char(20),
t_5 char(120),
t_6 char(20)
END RECORD
OUTPUT
LEFT MARGIN 0
TOP MARGIN 0
PAGE LENGTH 100
BOTTOM MARGIN 0
FORMAT
on every row
PRINT l_gdcl.tm_count ,",",
l_gdcl.t_1 ,",",
l_gdcl.t_2 ,",",
l_gdcl.t_3 ,",",
l_gdcl.t_4 ,",",
l_gdcl.t_5 ,",",
l_gdcl.t_6 ,","
END REPORT |
|