【问题标题】:Progress 4GL - Enumerable.Take(TSource) Method inProgress 4GL - 中的 Enumerable.Take(TSource) 方法
【发布时间】:2012-10-16 00:04:08
【问题描述】:

提前感谢您查看此问题!

这一切都在 FOR EACH 循环的上下文中,该循环可能会变得很长 - 想想 100,000 条记录 - 我正在寻找一种方法从该结果集中的某个位置获取 n 条记录,例如从 @ 4000 开始并获取接下来的 500 条记录。

我在 ABL 参考中四处寻找关键字,例如:

  • 位置
  • 前瞻
  • RECID - 我们是否可以在第 n 个位置找到 RECID
  • 查询调优

到目前为止还没有运气。有什么聪明人有提示吗?

【问题讨论】:

    标签: progress-4gl openedge


    【解决方案1】:

    这是我针对运动数据库创建的示例。体育数据库是一个示例数据库,类似于 SQL Server 中的 AdventureWorks 数据库。

    这应该让你开始:

    def var v-query as char   no-undo.
    def var h       as handle no-undo.
    
    /* Here is where can set a dynamic query */
    assign v-query = "for each orderline no-lock".
    
    /* Create handle used for query */
    create query h.
    
    /* Set the table against the query so you can access it conveniently */
    /* If you have other tables in your "for each", simply do a          */
    /* set-buffers on each table */
    h:set-buffers(buffer orderline:handle).
    
    /* Prepare Query */
    h:query-prepare(v-query).
    
    /* DO Open */
    h:query-open.
    
    /* Setup query to row 10 */
    h:reposition-to-row(10).
    
    LINE_LOOP:
    repeat:
    
       /* Read next row */
       h:get-next.
    
       /* Check if we are not past the end */
       if h:query-off-end then leave LINE_LOOP.
    
       /* Since we added orderline as a buffer we can now use it here */
       disp orderline.ordernum
            orderline.linenum
            orderline.itemnum
            orderline.price
            orderline.qty.
    
    end. /* repeat */
    
    h:query-close.
    

    仅供参考,Progress Knowledge basePSDN 有很好的示例和教程

    【讨论】:

    • 救生员特里!这是一些很棒的工作!不能感谢你。我会记住这件事很长一段时间!
    【解决方案2】:

    其他示例 - 填充数据集表 - BATCHING

    DEFINE TEMP-TABLE ttOrder LIKE Order.
    DEFINE DATASET dsOrder FOR ttOrder.
    
    /* you can set a buffer object */
    /*DEFINE DATA-SOURCE srcOrder FOR Order.*/
    
    /* or you can set a query */
    DEFINE QUERY qOrder FOR Order SCROLLING.
    QUERY qOrder:QUERY-PREPARE ("FOR EACH Order").
    DEFINE DATA-SOURCE srcOrder FOR QUERY qOrder.
    
    
    BUFFER ttOrder:ATTACH-DATA-SOURCE( DATA-SOURCE srcOrder:HANDLE ).
    
    /*The maximum number of ProDataSet temp-table rows to retrieve in each FILL operation.*/ 
    BUFFER ttOrder:BATCH-SIZE = 10. 
    
    /* Empties the table before the FILL operation begins. 
    Without setting this attribute will next rows append to existing in temp-table */
    BUFFER ttOrder:FILL-MODE = "EMPTY".  
    
    /* first time - result 1 - 10 */
    DATASET dsOrder:FILL ().
    
    FOR EACH ttOrder:
      DISPLAY ttOrder.ordernum.
    END.  
    
    /* set the startpoint to position 11 */
    DATA-SOURCE srcOrder:RESTART-ROW = 11.
    
    /* second time 11 - 20 */
    DATASET dsOrder:FILL ().
    
    FOR EACH ttOrder:
      DISPLAY ttOrder.ordernum.
    END.
    

    【讨论】:

      猜你喜欢
      • 2014-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-07
      • 2017-07-18
      • 2012-03-19
      • 2018-03-14
      相关资源
      最近更新 更多