如何从 Progress 4GL 中的字段访问多个元素
How can I access more than 1 element from a field in Progress 4GL
全部。我想从一个字段中获取多个元素。例如,如果 SQL 代码如下:
SELECT cod_emit, nom_abrev FROM emit WHERE cod_emit IN ('101','102','500');
我正在尝试使用 temp-tables 将其转换为 Progress,因此代码如下
DEF TEMP-TABLE tt-emit NO-UNDO
FIELD cod-emit LIKE emit.cod-emit
FIELD nom-abrev LIKE emit.nom-abrev.
FOR EACH emit
WHERE emit.cod-emit = 101
OR emit.cod-emit = 102
OR emit.cod-emit = 500 NO-LOCK:
CREATE tt-emit.
ASSIGN tt-emit.cod-emit = emit.cod-emit
tt-emit.nom-abrev = emit.nom-abrev.
END.
稍后,我将通过 JSON 获取临时 table 并将其用于我们的 .php。然而,我们需要使用的cod-emit将被用户插入到一个.php中。
我不知道在这种情况下我们是否可以使用逗号(但对于我所尝试的,我们不能)或者是否有任何其他解决方案来解决这个难题。谢谢你的时间。
你可能会这样做:
define temp-table tt_emit no-undo /* avoid using "-" in names */
cod_emit like emit.cod-emit
nom_abrev like emit.nom-abrev
/* it is not required but you really ought to define an index... */
.
define variable elist as character no-undo.
define variable ecode as character no-undo.
define variable i as integer no-undo.
define variable n as integer no-undo.
elist = '101,102,500'.
n = num-entries( elist ).
do i = 1 to n:
ecode = entry( i, elist ).
for each emit no-lock where emit.cod-emit = ecode:
create tt_emit.
assign
tt_emit.cod_emit = emit.cod-emit
tt_emit.nom_abrev = emit.nom-abrev
.
end.
end.
全部。我想从一个字段中获取多个元素。例如,如果 SQL 代码如下:
SELECT cod_emit, nom_abrev FROM emit WHERE cod_emit IN ('101','102','500');
我正在尝试使用 temp-tables 将其转换为 Progress,因此代码如下
DEF TEMP-TABLE tt-emit NO-UNDO
FIELD cod-emit LIKE emit.cod-emit
FIELD nom-abrev LIKE emit.nom-abrev.
FOR EACH emit
WHERE emit.cod-emit = 101
OR emit.cod-emit = 102
OR emit.cod-emit = 500 NO-LOCK:
CREATE tt-emit.
ASSIGN tt-emit.cod-emit = emit.cod-emit
tt-emit.nom-abrev = emit.nom-abrev.
END.
稍后,我将通过 JSON 获取临时 table 并将其用于我们的 .php。然而,我们需要使用的cod-emit将被用户插入到一个.php中。 我不知道在这种情况下我们是否可以使用逗号(但对于我所尝试的,我们不能)或者是否有任何其他解决方案来解决这个难题。谢谢你的时间。
你可能会这样做:
define temp-table tt_emit no-undo /* avoid using "-" in names */
cod_emit like emit.cod-emit
nom_abrev like emit.nom-abrev
/* it is not required but you really ought to define an index... */
.
define variable elist as character no-undo.
define variable ecode as character no-undo.
define variable i as integer no-undo.
define variable n as integer no-undo.
elist = '101,102,500'.
n = num-entries( elist ).
do i = 1 to n:
ecode = entry( i, elist ).
for each emit no-lock where emit.cod-emit = ecode:
create tt_emit.
assign
tt_emit.cod_emit = emit.cod-emit
tt_emit.nom_abrev = emit.nom-abrev
.
end.
end.