首页 > 解决方案 > RecordSortedList 和临时表

问题描述

我尝试使用 RecordSortedList 解决多个临时表的性能问题,但结果很奇怪。我有一个临时表,其中插入了几十万条记录,然后在其他地方用于连接到其他临时表。问题是在跟踪解析此解决方案后,插入对于所有单独的插入来说花费的时间太长,我希望使用 RecordSortedList 批量插入到临时表中。但是,在 RecordSortedList.insertDatabase() 调用之后,我找不到临时表的句柄。

我试过这样的事情:

RecordSortedList tmpTableSortedList;
MyTempTable myTempTable;
AssetTrans assetTrans;
int i = 1;

tmpTableSortedList = new RecordSortedList(tableNum(MyTempTable));
tmpTableSortedList.sortOrder(fieldNum(MyTempTable, LineNum));

//the real scenario has a much more complicated data gathering, but just for sample
while select * from AssetTrans 
{
    myTempTable.AssetGroup = assetTrans.AssetGroup
    myTempTable.LineNum = i;

    tmpTableSortedList.ins(myTempTable);

    i++;

}

tmpTableSortedList.insertDatabase();

//strange things happen here
MyTempTable myTempTableCopy;
AnotherTmpTable anotherTmpTable;

tmpTableSortedList.first(myTempTableCopy); //returns a buffer, but not usable buffer in join.

//does not work, I imagine because the myTempTableCopy isn't actually pointing to the 
//inserted records above; somehow the temp table is out of scope.
while select * from anotherTmpTable
join myTempTableCopy
where anotherTmpTable.id == myTempTableCopy.id
{
    //logic
}

有没有办法在调用 RecordSortedList.insertDatabase() 后获得指向临时表的指针?我也尝试过 linkPhysicalTable() 和其他一些东西,但也许 RecordSortedList 不应该与 tempDb 表一起使用?

编辑:就像 Aliaksandr 在下面指出的那样,这适用于RecordInsertList而不是RecordSortedList

标签: axaptax++dynamics-365-operations

解决方案


但也许 RecordSortedList 不应该与 tempDb 表一起使用?

使用TempDb表时的错误消息:

RecordInsertList or RecordSortedList operations are not allowed with database temporary tables.

所以这是不允许的,这可能是有道理的,因为RecordSortedList它是基于内存的对象而TempDb表不是。我认为你可以,因为我不确定当一个TempDb表和一个Regular表都存储在磁盘上时它们之间是否存在巨大差异?

如果您想使用InMemory表格,请特别查看使用表格\Classes\CustVendSettle的变量。rslTmpOverUnderReverseTaxInMemory

如果允许使用IF TempDb表,您可以使用getPhysicalTableName()将句柄与useExistingTempDBTable().

还是我看错了你的问题?


推荐阅读