-----Original Message----- From: Nikki Locke [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 06, 2006 6:06 AM To: sqlite-users@sqlite.org Subject: Re: [sqlite] a question about muticonnection
Hongdong wrote: > I just have a base question: > assume user A and user B now both connection to a same database and > both of them want to update a same record,but only one is allowed in > this condition: > A begin to browse the data in a client application,and load rowid into > GUI and keep it in memory. > B update the record which A want to update A now used the id stored in > memory to update the same record now it's wrong. > anyone can give me advice how to avoid this and keep the operation is Regarding: ... you can do it more easily with a timestamp on each record, which is updated every time the record is written - all you need to do then is to compare the timestamp. Since sqlite does not (inherently) have a central server, the clock of each connecting machine would be used for the timestamps. So I wonder if, even with fractional seconds, one might have duplicate timestamps. Even so, as long as one looks for *equality*, and doesn't depend on the newest timestamp as identifying the freshest update, then depending on your traffic, the timestamp might be sufficient. If I remember correctly, in a previous posting, I think Dr. H might have mentioned use of a random number for this purpose -- one with sufficient width to make collisions highly unlikely until long after our grandchildren cash in their retirement IRA's. ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------