Subject Re: How to 'lock' a table?
Author Adam
--- In firebird-support@yahoogroups.com, "Fabiano Bonin"
<fabianobonin@...> wrote:
>
> That's a good idea. Do you think the code below is safe?

No

>
> set term !! ;
>
> create or alter procedure sp_test
> as
> declare variable v integer;
> begin
> while (gen_id(mygen, 0) <> 0) do
> begin
> end

Two transactions could get to this point at the same time. Both would
be allowed to run your protected code.

> v = gen_id(mygen, 1);
>
> -- my stuff here
>
> v = gen_id(mygen, -1);
> end !!
>
> set term ; !!

Adam