You can try the below code. This was posted by one of our boarders.
create table testtab (f1 smallint,f2 char(3));
and here goes a demo stored procedure:
create procedure testtab_proc( mf1 char(8), mf2 char(7))
define cnt int;
set lock mode to wait;
while 1=1
insert into testtab values (mf1, mf2);
select dbinfo('sqlca.sqlerrd2') into cnt from
systables where tabid=1;
if cnt is null then
let cnt=0;
end if
if cnt = 1 then
exit while;
end if
end while
end procedure;
and finally this is how you may invoke the SPL using SQL:
execute procedure testtab_proc(1,'AAA');