Contents Index Setting the global database identifier Determining the most recently assigned value pdf/preface.pdf

UltraLite User's Guide
  Designing UltraLite Applications
    Global autoincrement default column values

How default values are chosen


The global database identifier in each deployed UltraLite application must be set to a unique, non-negative integer before default values can be assigned. These identification numbers uniquely identify the databases.

For information, see Setting the global database identifier.

The range of default values for a particular database is pn + 1 to p(n + 1), where p is the partition size and n is the global database identification number. For example, if the partition size is 1000 and the global database identification number is set to 3, then the range is from 3001 to 4000.

UltraLite applications choose default values by applying the following rules:

Caution    Column values downloaded via MobiLink synchronization do not update the default value counter. Thus, an error can occur should one MobiLink client insert a value into another client's partition. To avoid this problem, ensure that each copy of your UltraLite application inserts values only in its own partition.

If the global database identification number is set to the default value of 2147483647, a NULL value is inserted into the column. Should NULL values not be permitted, the attempt to insert the row causes an error. This situation arises, for example, if the column is contained in the table's primary key.

Because the global database identification number cannot be set to negative values, the values chosen are always positive. The maximum identification number is restricted only by the column data type and the partition size.

Null default values are also generated when the supply of values within the partition has been exhausted. In this case, a new global database identification number should be assigned to the database to allow default values to be chosen from another partition. Attempting to insert the NULL value causes an error if the column does not permit nulls.

Should the values in a particular partition become exhausted, you can assign a new database identification number to that database. You can assign new database id numbers in any convenient manner. However, one possible technique is to maintain a pool of unused database id values. This pool is maintained in the same manner as a pool of primary keys.

For information on determining whether the range of default values is becoming exhausted, see Detecting the number of available default values.

For information on maintaining primary key uniqueness using explicit primary key pools, see Maintaining unique primary keys.


Contents Index Setting the global database identifier Determining the most recently assigned value pdf/preface.pdf