2) DataMgr automatically handles assigning the UIDs. I first toyed with the idea of manually assigning sequential primary keys to each new record as follows: Store the next-unassigned Primary Key value in the DB's AppInfo block, use this as the primary key of the next-inserted record and then increment. This became problematic because a) the numeric value would eventually experience a wrap-around when it reached the maximum allowable value for its data type (UInt32), and b) after a wrap-around, how do you prevent assigning the same ID to two records? It seemed that Palm's UID system had already figured all of this out.
I've encountered problems with this approach in that if a PDB is beamed to another device the unique IDs can, and probably will, change. As a result all your references will be broken. What I've had to do to work around this is store the unique ID as a field in the data record. I then provide a function that the user can instruct the program to "resync the databases" which basically steps through each record and sets the unique ID from the value stored in the record.
I also don't believe that the Palm code guarantees that unique ID won't be duplicated. In particular if a PDB is moved to another machine the seed for the unique ID generator may overlap existing unique ID's. It's been a long time since I looked at this so I could be suffering from fuzzy memory here. If so someone please correct me.
Also if you generated your own unique ID based on a UInt32 value in appInfo you'd have to ad over 4 billion records to the database before the number wrapped. It might take a while.
Regards,
Bob
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
