Subject | Re: [IBO] PessimisticLocking - Trigger Before Update |
---|---|
Author | Helen Borrie |
Post date | 2004-10-20T12:54:33Z |
At 02:28 PM 20/10/2004 +0100, you wrote:
to use it, you need to design your update triggers to take it into
account. Some people add a do-nothing flag to the table, such as IsLocked:
create domain LockFlag as
smallint check (value is null or value = 1);
alter table aTable
add IsLocked LockFlag;
Then you can define custom LockSQL "update Atable set IsLocked = 1 where
<params>.."
Then, in the trigger,
as
begin
if (new.IsLocked = 1) then
EXIT;
else
/* Put all of the genuine trigger stuff inside this block */
begin
new.IsLocked = NULL,
blah....;
end
/* Don't add anything after this other than exception handlers */
end
Helen
>Hi,This is one of the big traps with this style of pess. locking. If you plan
>
>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?
to use it, you need to design your update triggers to take it into
account. Some people add a do-nothing flag to the table, such as IsLocked:
create domain LockFlag as
smallint check (value is null or value = 1);
alter table aTable
add IsLocked LockFlag;
Then you can define custom LockSQL "update Atable set IsLocked = 1 where
<params>.."
Then, in the trigger,
as
begin
if (new.IsLocked = 1) then
EXIT;
else
/* Put all of the genuine trigger stuff inside this block */
begin
new.IsLocked = NULL,
blah....;
end
/* Don't add anything after this other than exception handlers */
end
Helen