Functions.SetUnique Method (Logic)
Return and optionally change the setting that determines whether to include unique record keys in an order.
XSharp.Core (in XSharp.Core.dll) Version: 2.16
Syntax Request Example
lNewSetting AS LOGIC
) AS LOGIC
public static bool SetUnique(
- Type: Logic
TRUE creates orders with unique records only; FALSE creates orders with all records, even if their keys are the same.
The initial default is FALSE.
is not specified, SetUnique() returns the current setting.
is specified, the previous setting is returned.
SetUnique() is a database function that controls whether orders are created with uniqueness as an attribute. When TRUE is specified, new orders are created including only unique keys.
This is the same as creating an order with the INDEX...UNIQUE command.
The manner in which nonunique keys are handled in a unique order is determined by the RDD.
The standard behavior in most DBF-based RDDs is to include a record reference to a particular key value only once. Thus, if, during the creation or update of a unique order, two or more records are encountered with the same key value, only the first record is included in the order. When the unique order is updated, reindexed, or packed, only unique records are maintained, without regard to the current SetUnique() value.
Changing key values in a unique order has important implications. First, if a unique key is changed to the value of a key already in the order, the changed record is lost from the order. Second, if there is more than one instance of a key value in a database file, changing the visible key value does not bring forward another record with the same key until the order is rebuilt.
When FALSE is specified, orders are created with all records. Subsequent updates to the database files add all key values to the order independent of the current UNIQUE setting.
Note that keys from deleted records are also included in the index, and may hide keys from non-deleted records.
This example sets one routine to create orders with only records that have unique keys:
1LOCAL lUniqueSetting AS LOGIC
2lUniqueSetting := SetUnique(TRUE)