Problem description
To make it simple let's assume that records of
InventItemGroup
table in company USMF must be created in company USRT (provided the records are missing in USRT company). It seems to be possible to use cross-company query like this:InventItemGroup inventItemGroup, inventItemGroupJoin; while select crossCompany inventItemGroup where inventItemGroup.dataAreaId == 'USMF' notExists join inventItemGroupJoin where inventItemGroupJoin.dataAreaId == 'USRT' && inventItemGroupJoin.ItemGroupId == inventItemGroup.ItemGroupId { // create new record in USRT company } |
Steps to reproduce
The following job can be used for tests and analysis:
static void CrossCompanyTest(Args _args) { InventItemGroup inventItemGroup, inventItemGroupJoin; select generateonly forceLiterals crossCompany ItemGroupId from inventItemGroup where inventItemGroup.dataAreaId == 'USMF' notExists join inventItemGroupJoin where inventItemGroupJoin.dataAreaId == 'USRT' && inventItemGroupJoin.ItemGroupId == inventItemGroup.ItemGroupId; info(inventItemGroup.getSQLStatement()); } |
Hints
Try to modify predicates of join and use
Query
class instead of select statement.