微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

RecordSortedList和临时表

如何解决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()组合在一起。

还是我读错了你的问题?

,

不起作用,我想是因为myTempTableCopy实际上并不指向上面插入的记录;临时表超出了范围。

new的方法RecordSortedList具有附加的Common参数,您应该在其中传递tempDB表缓冲区。

enter image description here

使用TempDb表时的错误消息:

数据库临时表不允许使用RecordInsertList或RecordSortedList操作。

所以这是不允许的,这可能是有道理的,因为RecordSortedList是基于内存的对象,而TempDb表则不是。

尽管该消息说我们不能将临时表用于此类操作,但确实可以。我们只需要小心,因为代码必须在服务器上执行。

RecordSortedList objects must be server-located before the insertDatabase method can be called. Otherwise,an exception is thrown.

我有一个临时表,其中插入了数十万条记录

对RecordSortedList对象的大小没有限制,但是它们完全基于内存,因此存在潜在的内存消耗问题。因此,这可能不是您所需要的最佳解决方案。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。