Subject Re: [IBO] SQL Update where params
Author Helen Borrie
At 08:42 AM 2/07/2004 +0000, you wrote:
>I can see that my where params on sql update statements only use the
>key fields.

They only need the key fields. InterBase and Firebird never do field-level
updates.


>Is it possible to make it use all fields? in order to make it
>impossible to overwrite other users updates (optimistic locking).

You misunderstand how an update works.
The update will be
update thetable
set field1 = :field1
field2 = :field2
fieldnnn = ................
where ThePK = :ThePK
for as many fields as there are to update. If the way is clear, it will
replace the entire old record.


>I would like to avoid using the pesimistic locking scheme that the
>components provide,

Of course! Pessimistic locking is optional and by default it is false.

>because of the possibbly very long lasting locks.

You should never allow any locks (pessimistic or otherwise) to be long-lasting.

One user won't overwrite another user's changed record unless your
transaction settings are wrong. In ReadCommitted isolation, Set RecVersion
to False and LockWait to False to prevent the transaction from overwriting
another update on the record that is already pending at Post. In
Concurrency isolation, just set LockWait to False. In both these cases, be
ready to intercept error code 335544336 (isc_deadlock) inform the user of
the situation. If you use LockWait True instead, intercept 335544345
(isc_lock_conflict). Usually. LockWait is pointless for these two
particular configurations, since it will still fail, but will just take
longer to do so.

Helen