如何基于正在进行的用分隔符分隔的数据查询表 openedge 4gl.



我有一个字符串

a = "test1;test2;test3;test4;test5;".

我需要查询一个表(比如表),每个数据用";"分隔

我的查询是:

For each table where table.field1 matches "*test1*" no-lock:
    disp table.field1 table.field2
end.

虽然您的解决方案可以正常工作,但它有很多开销,特别是如果"for each"是一个缓慢的查询。您最好创建所需值的临时表并将其添加到查询中。当您使用"匹配"时,请确保 field1 处于不错的索引中,否则性能会很糟糕!

DEFINE VARIABLE v-cnt AS INTEGER     NO-UNDO.
DEFINE VARIABLE segment AS longchar   NO-UNDO.
define temp-table tt-element no-undo
  field element as character
  index elidx is primary element.
assign segment = "abc;bcd;efg;".
do v-cnt = 1 to num-entries(segment,';'):
  create tt-element.
  tt-element.element = entry(v-cnt,segment,';').
end. 
for each tt-element,
  each table1 no-lock
  where table1.field1 matches '*' + tt-element.element + '*':
  message table1.field1
    view-as alert-box info buttons ok.
end. 
DEFINE VARIABLE v-cnt AS INTEGER     NO-UNDO.
DEFINE VARIABLE segment AS longchar   NO-UNDO.
DEFINE VARIABLE eachelement AS CHARACTER   NO-UNDO.
assign segment = "abc;bcd;efg;".
DO v-cnt = 1 TO num-entries(segment, ";") - 1  :
ASSIGN eachelement = string(entry(v-cnt, segment, ";")).
FOR each table1 where table1.field1 matches "*" + eachelement + "*"  no-lock:
       MESSAGE table1.field1 
           VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
END.

相关内容

  • 没有找到相关文章

最新更新