如何使用 Progress 4GL 列出字段中的所有行
How to list all lines in a field with Progress 4GL
Progress 数据库中的地址字段显然是多行。所以如果我做一些简单的事情,比如:
for each customer where customer-number = "123" no-lock.
display customer-number
customer-name
customer-address.
我得到以下结果:
123 John Smith 123 Easy St.
c/o Jane Smith
Apartment C12
我想要以下结果:
123 John Smith 123 Easy St. c/o Jane Smith Apartment C12
我试过 Entry - 但如果元素不存在,则会出现错误。我正在尝试导出到 CSV 并希望每一行成为另一列,如果一列不存在则它是空白的。
任何帮助将不胜感激!
如果分隔符是一个换行符,那么这样的事情应该有效:
define variable n as integer no-undo.
define variable i as integer no-undo.
define variable address as character no-undo.
output to value( "customer.csv").
for each customer no-lock:
address = "".
n = num-entries( customer-address, "~n" ).
do i = 1 to n:
address = address + entry( i, customer-address, "~n" ) + " ".
end.
export delimiter "," customer-number customer-name trim( address ).
end.
output close.
或者,如果您只需要更改客户地址字段中的分隔符:
output to value( "customer.csv").
for each customer no-lock:
export delimiter "," customer-number customer-name replace( customer-address, "~n", "," ).
end.
output close.
(而且,实际上,我的原始代码实际上只是将 ~n 替换为 space,因此您也可以这样做...)
Progress 数据库中的地址字段显然是多行。所以如果我做一些简单的事情,比如:
for each customer where customer-number = "123" no-lock.
display customer-number
customer-name
customer-address.
我得到以下结果:
123 John Smith 123 Easy St.
c/o Jane Smith
Apartment C12
我想要以下结果:
123 John Smith 123 Easy St. c/o Jane Smith Apartment C12
我试过 Entry - 但如果元素不存在,则会出现错误。我正在尝试导出到 CSV 并希望每一行成为另一列,如果一列不存在则它是空白的。
任何帮助将不胜感激!
如果分隔符是一个换行符,那么这样的事情应该有效:
define variable n as integer no-undo.
define variable i as integer no-undo.
define variable address as character no-undo.
output to value( "customer.csv").
for each customer no-lock:
address = "".
n = num-entries( customer-address, "~n" ).
do i = 1 to n:
address = address + entry( i, customer-address, "~n" ) + " ".
end.
export delimiter "," customer-number customer-name trim( address ).
end.
output close.
或者,如果您只需要更改客户地址字段中的分隔符:
output to value( "customer.csv").
for each customer no-lock:
export delimiter "," customer-number customer-name replace( customer-address, "~n", "," ).
end.
output close.
(而且,实际上,我的原始代码实际上只是将 ~n 替换为 space,因此您也可以这样做...)