如果其字段数据类型为 LIKE table-name,如何从 temp table 获取标签 - Progress 4GL?
How to get labels from temp table if its field datatype is LIKE table-name - Progress 4GL?
我是 progress 4GL 的新手。我总是使用下面的查询将数据从 temp table 导出为 .csv 文件。为了给 header 标签,我已经硬编码了。是否可以从 temp table 字段本身获取标签?如果是,请帮助我修改查询。
DEFINE TEMP-TABLE ttdata NO-UNDO
FIELD cCustomerName LIKE Customer.NAME
FIELD cAddress LIKE Customer.Address
.
OUTPUT TO VALUE(SESSION:TEMP-DIRECTORY + "temp.csv").
PUT UNFORMATTED "customer Name,Customer Address" SKIP.
FOR EACH ttdata NO-LOCK:
EXPORT DELIMITER "," ttdata.
END.
OUTPUT CLOSE.
您可以像这样迭代 temp-table 的默认缓冲区的缓冲区字段:
DEFINE TEMP-TABLE ttdata NO-UNDO
FIELD cCustomerName LIKE Customer.NAME
FIELD cAddress LIKE Customer.Address
FIELD cMonthQuota LIKE Salesrep.MonthQuota
.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE j AS INTEGER NO-UNDO.
DEFINE VARIABLE iCount AS INTEGER NO-UNDO.
DEFINE VARIABLE iExtent AS INTEGER NO-UNDO.
OUTPUT TO VALUE(SESSION:TEMP-DIRECTORY + "temp.csv").
ASSIGN iCount = BUFFER ttData:NUM-FIELDS .
DO i = 1 TO iCount:
iExtent = BUFFER ttData:BUFFER-FIELD (i):EXTENT .
IF iExtent > 1 THEN
DO:
DO j = 1 TO iExtent:
PUT UNFORMATTED
(IF i > 1 OR j > 1 THEN "," ELSE "")
SUBSTITUTE ("&1[&2]",
BUFFER ttData:BUFFER-FIELD (i):LABEL,
j) .
END.
END.
ELSE
PUT UNFORMATTED
(IF i > 1 THEN "," ELSE "")
BUFFER ttData:BUFFER-FIELD (i):LABEL .
END.
PUT UNFORMATTED SKIP.
FOR EACH ttdata NO-LOCK:
EXPORT DELIMITER "," ttdata.
END.
OUTPUT CLOSE.
header 的字符变量减少了噪声量:
var int ifields,ic,icx.
var handle hb,hf.
var char cheader.
define temp-table ttdata no-undo
field customername like customer.name
field address like customer.address
field monthquota like salesrep.monthquota
.
output to value( session:temp-directory + 'temp.csv' ).
hb = buffer ttdata:handle.
ifields = hb:num-fields.
do ic = 1 to ifields:
hf = hb:buffer-field( ic ).
do icx = if hf:extent > 0 then 1 else 0 to hf:extent:
cheader = cheader + ',' + hf:name.
if icx > 0 then
cheader = cheader + '[' + string( icx ) + ']'.
end.
end.
put unformatted substring( cheader, 2 ) skip.
for each ttdata no-lock:
export delimiter ',' ttdata.
end.
output close.
https://abldojo.services.progress.com/?shareId=624995c73fb02369b25437c5
我是 progress 4GL 的新手。我总是使用下面的查询将数据从 temp table 导出为 .csv 文件。为了给 header 标签,我已经硬编码了。是否可以从 temp table 字段本身获取标签?如果是,请帮助我修改查询。
DEFINE TEMP-TABLE ttdata NO-UNDO
FIELD cCustomerName LIKE Customer.NAME
FIELD cAddress LIKE Customer.Address
.
OUTPUT TO VALUE(SESSION:TEMP-DIRECTORY + "temp.csv").
PUT UNFORMATTED "customer Name,Customer Address" SKIP.
FOR EACH ttdata NO-LOCK:
EXPORT DELIMITER "," ttdata.
END.
OUTPUT CLOSE.
您可以像这样迭代 temp-table 的默认缓冲区的缓冲区字段:
DEFINE TEMP-TABLE ttdata NO-UNDO
FIELD cCustomerName LIKE Customer.NAME
FIELD cAddress LIKE Customer.Address
FIELD cMonthQuota LIKE Salesrep.MonthQuota
.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE j AS INTEGER NO-UNDO.
DEFINE VARIABLE iCount AS INTEGER NO-UNDO.
DEFINE VARIABLE iExtent AS INTEGER NO-UNDO.
OUTPUT TO VALUE(SESSION:TEMP-DIRECTORY + "temp.csv").
ASSIGN iCount = BUFFER ttData:NUM-FIELDS .
DO i = 1 TO iCount:
iExtent = BUFFER ttData:BUFFER-FIELD (i):EXTENT .
IF iExtent > 1 THEN
DO:
DO j = 1 TO iExtent:
PUT UNFORMATTED
(IF i > 1 OR j > 1 THEN "," ELSE "")
SUBSTITUTE ("&1[&2]",
BUFFER ttData:BUFFER-FIELD (i):LABEL,
j) .
END.
END.
ELSE
PUT UNFORMATTED
(IF i > 1 THEN "," ELSE "")
BUFFER ttData:BUFFER-FIELD (i):LABEL .
END.
PUT UNFORMATTED SKIP.
FOR EACH ttdata NO-LOCK:
EXPORT DELIMITER "," ttdata.
END.
OUTPUT CLOSE.
header 的字符变量减少了噪声量:
var int ifields,ic,icx.
var handle hb,hf.
var char cheader.
define temp-table ttdata no-undo
field customername like customer.name
field address like customer.address
field monthquota like salesrep.monthquota
.
output to value( session:temp-directory + 'temp.csv' ).
hb = buffer ttdata:handle.
ifields = hb:num-fields.
do ic = 1 to ifields:
hf = hb:buffer-field( ic ).
do icx = if hf:extent > 0 then 1 else 0 to hf:extent:
cheader = cheader + ',' + hf:name.
if icx > 0 then
cheader = cheader + '[' + string( icx ) + ']'.
end.
end.
put unformatted substring( cheader, 2 ) skip.
for each ttdata no-lock:
export delimiter ',' ttdata.
end.
output close.
https://abldojo.services.progress.com/?shareId=624995c73fb02369b25437c5