we have the same error and opened an MS request to get an solution. The exam result you'll find below.
It's only a workaround and the needed kernel fix might come or not :-).
The behaviour of the TZID fields is explained here:
https://msdn.microsoft.com/en-us/library/cc622312.aspx
As the article mentions, the hidden TZID field is only added for AOT fields:
When you use the Application Object Tree (AOT) to add a DateTime field named MyDateTime to a table, the following two fields are added to the database table:
-
MyDateTime
-
MyDateTimeTZId
So the field is not added for system fields that don’t show up in the AOT, such as ModifiedDateTime.
If you test with a table that actually has an AOT DateTime field, the insert works fine, for instance:
BatchJob custTable;
insert_recordset testTable (Key, TimeStamp)
select Caption, StartDateTime from custTable;
The problem occurs at kernel level when the insert_recordset statement is generated, since we need to write three fields in TestTable (Key, TimeStamp and TimeStampTZID) but we don’t have the same fields in CustTable, only the first two.
The question now is what the business impact is and it all revolves around how this code is used in production. A kernel fix in this area is very risky and the benefit is not very clear until we know if the workaround is viable or not.
If this functionality is needed, we can use the following workaround. The downside is a possible reduction in performance so if that’s the case, we need to know what the performance is on the customer’s side.
static void _TestScriptFix(Args _args)
{
_TestTable testTable;
CustTable custTable;
if ((select firstOnly RecId from CustTable).RecId == 0)
throw warning("Create some customers before running this test!");
ttsBegin;
delete_from testTable;
insert_recordset testTable (Key)
select AccountNum from custTable;
ttsCommit;
info("The Key column has been successfully inserted.");
ttsBegin;
delete_from testTable;
while select AccountNum, ModifiedDateTime from custTable
{
testTable.Key = custTable.AccountNum;
testTable.TimeStamp = custTable.modifiedDateTime;
testTable.insert();
}
/*insert_recordset testTable (Key, TimeStamp)
select AccountNum, ModifiedDateTime from custTable;*/
ttsCommit;
info("The Key AND TimeStamp column has been successfully inserted.");
}