Try OpenEdge Now
skip to main content
Programming Interfaces
Database Administration Entity Interface Reference : ITable interface : ITable examples : Managing partitions for a table
 
Managing partitions for a table
The following code enables a table for multi-tenancy and changes the area for its index, field, and table partitions. It also uses the Allocate( ) methods on the table partitions, which also allocate the index and field partitions of the table. (The Allocate( ) method cannot be used directly on index and field partitions):
using OpenEdge.DataAdmin.*.
using OpenEdge.DataAdmin.Lang.Collections.*.

define variable service as DataAdminService no-undo.
define variable tableImpl as ITable no-undo.
define variable iterator as IIterator no-undo.
define variable iterator2 as IIterator no-undo.
define variable partition as IPartition no-undo.

assign
  service = new DataAdminService("sportsmt")
  tableImpl = service:GetTable("Customer")
  tableImpl:IsMultitenant = true.
  
service:UpdateTable(tableImpl).
iterator = TableImpl:LOBFields:Iterator().
do while iterator:HasNext():
  iterator2 = cast(iterator:Next(),IField):Partitions:Iterator("AllocationState <> 'Allocated'").
  do while iterator2:HasNext():
    partition = cast(iterator2:Next(),IPartition).
    partition:Area = service:GetArea("ExpressLobArea").
  end.
end.

iterator = TableImpl:Indexes:Iterator().
do while iterator:HasNext():
  iterator2 = cast(iterator:Next(),IIndex):Partitions:Iterator("AllocationState <> 'Allocated'").
  do while iterator2:HasNext():
    partition = cast(iterator2:Next(),IPartition).
    partition:Area = service:GetArea("ExpressIndexArea").
  end.
end.

iterator = tableImpl:Partitions:Iterator("AllocationState <> 'Allocated'").
do while iterator:HasNext():
  partition = cast(iterator:Next(),IPartition).
  partition:Area = service:GetArea("ExpressDataArea").
  partition:Allocate().
end.
service:UpdateTable(tableImpl).
Note: The invocation of partition:Allocate( )is specified only for table partitions (in the final DO loop), because all LOB field and index partitions are allocated automatically along with their parent table partitions.
See also:
*IField interface
*IFieldSetinterface
*IIndex interface
*IIndexSetinterface
*IPartitioninterface
*IPartitionOwnerinterface
*ISchemaElementinterface
*ITableSetinterface