0

提前感谢您查看此问题!

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

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

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

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

4

2 回答 2

3

这是我针对体育数据库创建的示例。体育数据库是一个示例数据库,类似于 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.

仅供参考,进度知识库PSDN有很好的示例和教程

于 2012-10-16T05:13:07.767 回答
0

其他示例 - 填充数据集表 - 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.
于 2012-10-17T10:05:54.517 回答