Try OpenEdge Now
skip to main content
Programming Interfaces
Data Management : Multi-tenant ABL : Coding for super-tenant access : Super-tenant queries : SKIP-GROUP-DUPLICATES option of TENANT-WHERE
 
SKIP-GROUP-DUPLICATES option of TENANT-WHERE
If a multi-tenant table is configured with a tenant group, a single instance of the table is shared by all tenants in the group (see OpenEdge Getting Started: Multi-tenancy Overview). This means that if a super tenant queries the table for all tenants in the group, the query returns exactly the same records once for each tenant in the group.
For example, if two or more tenants are in a group configured for the Customer table, the following example displays the same Customer data for the group multiple times—once for every tenant in the group:
FOR EACH Customer TENANT-WHERE TENANT-ID >= 0:
  DISPLAY CustNum.
END.
Because the group data is common to all the tenants in the group, you see that same record once when the TENANT-WHERE processes the first member of the group, once again when the TENANT-WHERE processes the second member of the group, and so on. You may want this if you are referring to other tables in the FOR EACH statement that do not have the same grouping, since they would be missed otherwise. But if you have a very simple case like the example above, with no join or other references to groups that do not have the same tenant membership, you probably want to skip the duplicate data. In that case you can use the SKIP-GROUP-DUPLICATES option.
This example only displays group data for the first member of the group, and skips tenants that belong to the same group that has already been processed:
FOR EACH Customer TENANT-WHERE TENANT-ID >= 0 SKIP-GROUP-DUPLICATES:
  DISPLAY CustNum.
END.
This is not the default behavior, because you typically do have references to other tables in a FOR EACH block or in a query.