--
-- ### select for update checks
--

create table ids ( id string(30), idval int );
insert into ids values ( 'ONR', 100);

@
create procedure nextid ( id in string(30) ) return int 
begin 

   var nextVal int;

   update ids set idval = idval + 1 where id = :id return :nextVal = idval;

   return :nextVal;

end;
@

select * from ids;
:r = call nextid( 'ONR' );
print :r;
select * from ids;

:r = call nextid( 'ONR' );
print :r;


drop procedure nextid;
drop table ids;
