Subject | Re: Record versioning/timestamping |
---|---|
Author | gregatacd |
Post date | 2004-12-21T02:37Z |
Actually, I'm more concerned about having the application check for
changes while I'm editing records. For example, in my application
user A will read a record from the database and have it presented
for viewing/editing. User A will then edit this data (over the
course of a few minutes). Meanwhile, User B (who had also pulled the
same record a bit earlier) updates the database with their changes.
So, when User A submits their changes, I want to know if the data
for that record has changed in the meantime, and deal with that in
some appropriate way. Thus the need for a timestamp/counter marker
to detect these changes; I can use this column to compare the
original value to the current value.
I suppose I could use a single generator for all records to populate
this column, but I could also simply increment the column in the
before update trigger... I just want to be sure that this will be a
fully atomic operation. This will also be more cross-DB platform
friendly (not many DBs have this fine generator feature), and will
give an audit as to how many times the record has been updated (it
may be useful information at some point...).
Greg
--- In firebird-support@yahoogroups.com, "Adam" <s3057043@y...>
wrote:
changes while I'm editing records. For example, in my application
user A will read a record from the database and have it presented
for viewing/editing. User A will then edit this data (over the
course of a few minutes). Meanwhile, User B (who had also pulled the
same record a bit earlier) updates the database with their changes.
So, when User A submits their changes, I want to know if the data
for that record has changed in the meantime, and deal with that in
some appropriate way. Thus the need for a timestamp/counter marker
to detect these changes; I can use this column to compare the
original value to the current value.
I suppose I could use a single generator for all records to populate
this column, but I could also simply increment the column in the
before update trigger... I just want to be sure that this will be a
fully atomic operation. This will also be more cross-DB platform
friendly (not many DBs have this fine generator feature), and will
give an audit as to how many times the record has been updated (it
may be useful information at some point...).
Greg
--- In firebird-support@yahoogroups.com, "Adam" <s3057043@y...>
wrote:
>alter
> Firstly, once you alter a record, it will not let another user
> that record until you commit or rollback (its called a multiversiontransaction
> record), so it may not even be an issue for you. Depending on what
> transaction mode you use, their query will wait for your
> to commit/rollback or generate an exception.and
>
> If you still want a record stamp, create a 64 bit integer column
> fill it using a generator. You may want to use a trigger to setit, or
> you can return it to the calling program. Generators are threadsafe too.
><GregAtACD@h...>
> Adam
>
> --- In firebird-support@yahoogroups.com, "gregatacd"
> wrote:when I
> >
> > DB: Firebird 1.5
> >
> > I'm looking for a way to mark a record as being updated. For
> > example, I read a record with a timestamp or other mark, then
> > update it (after the user enters some changes etc.), I find thatthe
> > mark has changed somehow (another user updating the recordtime.
> > underneath me).
> >
> > What would be the best way to mark a record as updated or added?
> >
> > One potential solution would be to create a timestamp column and
> > have an update/insert trigger update the timestamp column each
> > Is there a performance issue with this (since getting thecurrent
> > time may not be overly quick, and it must be done once perthis
> > update/insert).
> >
> > Or, add a 64bit integer column and have the triggers do a +1 on
> > column... would this be 'atomic' enough given that multipleusers
> > may be editing a given record...
> >
> > Any advice here on best practices would be great!
> >
> > Greg