Contents Index Setting unique database identification numbers when extracting databases Maintaining unique primary keys using key pools

MobiLink Synchronization User's Guide
  Synchronization Techniques
    Maintaining unique primary keys
      Maintaining unique primary keys using global autoincrement

How default values are chosen

The public option GLOBAL_DATABASE_ID in each database must be set to a unique, non-negative integer. 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 value of the public option GLOBAL_DATABASE_ID. For example, if the partition size is 1000 and GLOBAL_DATABASE_ID is set to 3, then the range is from 3001 to 4000.

If GLOBAL_DATABASE_ID is set to a non-negative integer, Adaptive Server Anywhere chooses default values by applying the following rules:

If the public option GLOBAL_DATABASE_ID 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 public option GLOBAL_DATABASE_ID 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 value of GLOBAL_DATABASE_ID 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. To detect that the supply of unused values is low and handle this condition, create an event of type GlobalAutoincrement.

Should the values in a particular partition become exhausted, you can assign a new database id 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.

You can set an event handler to automatically notify the database administrator (or carry out some other action) when the partition is nearly exhausted. For more information, see Defining trigger conditions for events.

For more information, see Setting the GLOBAL_DATABASE_ID value, and GLOBAL_DATABASE_ID option [database].


Contents Index Setting unique database identification numbers when extracting databases Maintaining unique primary keys using key pools