declare
   nomdl number;
   currmdl number;

begin
   select count(m.module_name) into nomdl from nx_modules m, nx_projects p
   where   p.origin='B'
   and     p.project_name = m.project_name
   and     p.language_code = m.language_code;
   select mdl_seq into currmdl from nx_mdl_seq for update nowait;
   update nx_mdl_seq set mdl_seq = currmdl + nomdl;

   insert into nx_module select currmdl+rownum-1, m.module_name, m.module_type,
       p.project_id from nx_modules m, nx_project p
       where p.name = m.project_name
       and p.language_code = m.language_code;
   commit;
end;
/

