--
-- ### Table lock checks
--

drop if exists table t1;
drop if exists procedure updatetab;
create table t1 ( a int, b string(30), c int);
create btree i1 on t1(a);

insert into t1 values ( 1, 'fred', 0);
insert into t1 values ( 2, 'mark', 0);
insert into t1 values ( 3, 'berta', 0);
insert into t1 values ( 4, 'john', 0);
insert into t1 values ( 5, 'anna', 0);

@
create procedure updatetab ( numupd in int )
begin 

   while :numupd > 0
   begin

	lock table t1;
	update t1 set c = c+1 where a = 3;
	unlock table t1;
	:numupd = :numupd - 1;
   end;
end;
@

call updatetab(1000);

select * from t1;

drop table t1;
drop procedure updatetab;
