At 11:01 PM -0700 4/5/04, Keith Herold wrote:
I have an in-memory db that periodically writes to a disk db (there are good
reasons for this).  Later, I may need a connection to that disk db via
another memory db, but any inserts from that connection need to take place
at the appropriate autoincrement value.  So, suppose I last wrote to the
disk db and ended at autoincrement = 514 .  Later, I reconnect, but need the
new in-memory db to start incrementing inserts at 515, 516, etc., so that
the eventual write to the disk db is synchronized correctly (I will not be
hitting the upper limit on rows, so I am not worrying about reusing
autoincrements).

Assuming the trivial case where only one process is using the on disk database, I would recommend that the on disk database is set so that you manually set the primary key value and that only the in memory database auto increments. When saving an in-memory record to disk, you just copy the whole row, including the already set primary key value. You can avoid overlaps by seeding your in memory database as your process starts up. The first thing it would do is query the on disk database with a "select max(pk_name) from tbl_name" to get a seed value. Then any new auto incremented values will start higher than the highest already there. Of course, if your case is non-trivial and you have multiple processes sharing the disk database, then you will need a very different solution. -- Darren Duncan


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to