【问题标题】:How can i use FOR each, going through the table for one of the fields ascending in OpenEdge?我如何使用 FOR 每个,遍历表以获取 OpenEdge 中升序的字段之一?
【发布时间】:2014-11-19 08:21:19
【问题描述】:

例如,我有一个带有字段“sub_id”的表,该表未按升序或降序排序。我想从最小的 sub_id 到最大的 FOR EACH,我该怎么做?

【问题讨论】:

    标签: progress-4gl openedge


    【解决方案1】:

    您应该使用关键字 BY。如果您排序的字段没有被索引,这可能会很慢并且会消耗系统资源。这在一张大桌子上最为明显。

    /* Smallest to largest */
    FOR EACH tablename NO-LOCK BY tablename.sub_id:
      /* Do something */
    END.
    
    /* Largest to smallest sub_id */
    FOR EACH tablename NO-LOCK BY tablename.sub_id DESCENDING:
      /* Do something */
    END.
    
    /* With a WHERE clause */
    FOR EACH tablename NO-LOCK WHERE tablename.field = "something" BY tablename.sub_id:
      /* Do something */
    END.
    

    如果您想更改数据(更新、分配等),上述 NO-LOCK 将不起作用。 NO-LOCK 用于只读操作(如显示数据)。 EXCLUSIVE-LOCK 用于更新/删除等。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-20
      • 1970-01-01
      • 1970-01-01
      • 2017-10-13
      • 1970-01-01
      • 1970-01-01
      • 2021-11-22
      • 2010-10-17
      相关资源
      最近更新 更多