createPartition(): Integer64;
The createPartition method of the DbFile class creates a new empty database file partition and returns the partition identifier.
You can make a number of related createPartition operations atomic, by containing them in the same database transaction, as shown in the following example.
// execute just before midnight at end of current period beginTransaction; Order.getDbFile.createPartition; OrderItem.getDbFile.createPartition; // execute just after midnight at start of next period commitTransaction;
When the createPartition operation is invoked on a partitioned database file, any transactions that attempt to create new instances are blocked until the transaction that invoked the createPartition operation commits or aborts.
An exception is raised if the database file is locked for reorganization or if the file is not partitioned.
The following restrictions apply to the use of the createPartition method.
Partitions can be created only within a transaction
No other partition creation operation can be in progress
Persistent objects cannot be created or updated in the transaction that creates a partition
Persistent objects cannot be created in a partitioned file by any user while a new partition for that file is being created
For a production application, you should implement a synchronization mechanism to prevent the creation of objects stored in a partitioned file while a new partition is created.