Subject | Re: [firebird-support] Re: Triggers suitability |
---|---|
Author | Hans |
Post date | 2005-10-07T02:31:58Z |
Just add an field say called 'version' BigInt to your DB Record and add a
trigger for insert and update, which updates this field via a Generator. Now
when you read the record, before you post, check if the value of 'version'
is still the same, if not, someone else updated the record in the meantime.
Create Generator Gen_Version
In trigger before insert and update
New.Version = Gen_ID(Gen_Version,1);
If you use a different Generator for each Table of interest, the check for
the 'version' value merely has
to be a Gen_ID(Gen_Version,0) call
---------------------------------------------------------------------------------------------
trigger for insert and update, which updates this field via a Generator. Now
when you read the record, before you post, check if the value of 'version'
is still the same, if not, someone else updated the record in the meantime.
Create Generator Gen_Version
In trigger before insert and update
New.Version = Gen_ID(Gen_Version,1);
If you use a different Generator for each Table of interest, the check for
the 'version' value merely has
to be a Gen_ID(Gen_Version,0) call
---------------------------------------------------------------------------------------------
----- Original Message -----
From: "yeohray" <yeohray@...>
To: <firebird-support@yahoogroups.com>
Sent: Thursday, October 06, 2005 8:22 PM
Subject: [firebird-support] Re: Triggers suitability
> Thanks for the information. Is it possible to retrieve this 'record
> version' value? I was thinking if it could be used to detect changes
> to records (related to my question on avoiding pessimistic locking).
> Thanks.
>
> Ray Mond
>
>
> -- In firebird-support@yahoogroups.com, "Ann W. Harrison"
> <aharrison@i...> wrote:
>>
>> Firebird uses multi-generational concurrency control. That means
> that
>> when you modify a record, Firebird creates a new version of the
> record
>> and keeps the old one around so that other transactions can
> continue to
>> see it. When you delete a record, Firebird creates a new record
> version
>> that says that the record is deleted, leaving the old record
> version.
>> When your transaction commits and all transactions that were
> concurrent
>> with it end, the old versions become uninteresting - useless
> garbage in
>> fact. All transactions (and a garbage collect thread) remove
>> unnecessary old versions of records as they are encountered.
>>
>>
>> Regards,
>>
>>
>> Ann
>>
>
>
>
>
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>