axapta - 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
解决方案
但也许 RecordSortedList 不应该与 tempDb 表一起使用?
使用TempDb
表时的错误消息:
RecordInsertList or RecordSortedList operations are not allowed with database temporary tables.
所以这是不允许的,这可能是有道理的,因为RecordSortedList
它是基于内存的对象而TempDb
表不是。我认为你可以,因为我不确定当一个TempDb
表和一个Regular
表都存储在磁盘上时它们之间是否存在巨大差异?
如果您想使用InMemory
表格,请特别查看使用表格\Classes\CustVendSettle
的变量。rslTmpOverUnderReverseTax
InMemory
如果允许使用IF TempDb
表,您可以使用getPhysicalTableName()
将句柄与useExistingTempDBTable()
.
还是我看错了你的问题?
推荐阅读
- c - 使用 malloc() 在 C 中的方法中初始化 cstrings 数组
- c# - 在同一天但不同时间的日期时间列表中查找空白
- webpack - Webpack - 是否可以最小化包依赖?
- python - Python - 更改列表中特定单词的区分大小写
- java - 如何获取JavaFX程序控制器内部的调用节点
- java - 终端输出 Vscode
- ruby-on-rails - Rspec:如何显示测试文件的覆盖率
- javascript - 只需一行代码即可将类的 disable 属性设置为 true
- python - 在python中打印带有条件的字符串
- ios - 发生单元格内容交互时更新 TableView 单元格高度