Subject Re: [firebird-support] Select with lock does not lock
Author Alexandre Benson Smith
Gustavo wrote:
> Perhaps the problem is that when the second SELECT executes it only fetches
> one record (instead of six) and then it locks (immediately after execution)
> only one record. If this is the problem, how can I know how many records a
> SELECT will fetch? Can I change the number of records that a SELECT
> statement will fetch?
> Gustavo
Hi Gustavo !

I have no pratical experience with the WITH LOCK clause, but as far as I
understand when you try to fetch a record that is already locked by
another statement the lock conflict happens (and this is what you want,
right ?).

If so, just do a fetch all on both queries, the first you lock all
records, the second will fail when try to fetch an already locked record.

Don't know you business requirements neither the way your system will be
used with this, but I woluld expect a lot of lock conflicts in such
scenario. :-/ Worst will be if the user open this query with lock option
and go to lunch .:-(

see you !

Alexandre Benson Smith
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil