我有一条记录,让我们说100行,用户标记。我检索这样的记录:
CurrPage.SETSELECTIONFILTER(recSelection);
recSelection.FINDSET;
现在,我想一次将20行选择复制到另一个记录变量中并将其传递给函数。
我如何逐步处理记录? 像这样的东西:
batchSize := 20;
currSize := 0;
totalSize := recSelection.COUNT;
totalProcessed := 0;
recSelection.FINDSET;
REPEAT
IF (currSize = 0) THEN BEGIN
tmpRec.INIT;
END;
// how can I add the current to the tmp?
// tmpRec.INSERT -> recSelection
currSize += 1;
totalProcessed += 1;
IF (currSize = batchSize) OR (totalProcessed = totalSize) THEN BEGIN
SomeHeavyFunction(tmpRec);
currSize := 0;
END;
UNTIL recSelection.NEXT = 0;
答案 0 :(得分:0)
我得到了它的工作:
(带有临时记录的deleteall对我来说总是有点可怕:P),recTemp是临时记录
CURR_BATCH_SIZE := 0;
TOTAL_ITEMS := recSelected.COUNT;
BATCH_SIZE := 20;
TOTAL_PROCESSED := 0;
IF recSelected.FIND('-') THEN
REPEAT
IF (CURR_BATCH_SIZE = 0) THEN BEGIN
recTemp.RESET;
recTemp.DELETEALL;
recTemp.INIT;
END;
// copy over
recTemp := recSelected;
recTemp.INSERT;
// store state
CURR_BATCH_SIZE := CURR_BATCH_SIZE + 1;
TOTAL_PROCESSED := TOTAL_PROCESSED + 1;
// did we reach batch limit or end?
IF (CURR_BATCH_SIZE = BATCH_SIZE) OR (TOTAL_PROCESSED = TOTAL_ITEMS) THEN BEGIN
// process batch
MESSAGE('Processing next %1. total processed %2/%3', FORMAT(recTemp.COUNT), FORMAT(TOTAL_PROCESSED), FORMAT(TOTAL_ITEMS));
// reset counters
CURR_BATCH_SIZE := 0;
END;
UNTIL recSelected.NEXT = 0;
答案 1 :(得分:0)
根据您的版本,您可以查看recTemp.ISTEMPORARY
。
有关详细信息,请参阅documentation。