declare
   novrn number;
   currvrn number;

begin
   select count(*) into novrn from nx_versions v, nx_projects p
   where   p.origin='B'
   and     p.project_name = v.project_name
   and     p.language_code = v.language_code;
   select vrn_seq into currvrn from nx_vrn_seq for update nowait;
   update nx_vrn_seq set vrn_seq = currvrn + novrn;

   insert into nx_version select currvrn+rownum-1, v.version_number,
       m.project_id, m.module_id from nx_versions v, nx_module m, nx_project p
       where p.name = v.project_name
       and m.name = v.module_name
       and p.project_id = m.project_id
       and p.language_code = v.language_code;
   commit;
end;
/
