Subject Re: PessimisticLocking - Trigger Before Update
Author Svein Erling Tysvær
--- In IBObjects@yahoogroups.com, "Vincenzo Scarpellino" wrote:
> Hi,
>
> When I set PessimisticLocking = True in a IBOQuery and I edit a
> record it suddenly fires 'Before Update Trigger' before of post
> record and than when post record.
>
> Why ? How can I avoid it, without to be constrained to evaluate
> every field before to perform operations in trigger?
>
> Thank You

Firebird uses optimistic locking. To make pessimistic locking possible
(appropriate only in rare cases), IBO makes an update like

update <table>
set <pk> = <pk>
where <pk> = <value>

The way to avoid this is to not use pessimistic locking. Another
option if you really need pessimistic locking, is to modify your
trigger to check for any changes to the record before executing
whatever you currently do in your trigger. I don't think it is
possible to use pessimistic locking without using this update clause
(hopefully others will tell if I'm wrong), but of course you can
circumvent it by e.g. always modify one field in your database when
there are real changes and only check that one field in your trigger.

Set