   execute alter_seq_stmt; 
   deallocate prepare alter_seq_stmt;
   
-  select max(numericVal(PERM_ID)) + 1 into l_new_seq from KRIM_PERM_T where numericVal(PERM_ID) < 10000;
+  select ifnull(max(numericVal(PERM_ID)) + 1,1) into l_new_seq from KRIM_PERM_T where numericVal(PERM_ID) < 10000;
   set @create_seq := 'CREATE TABLE KRIM_PERM_ID_BS_S (id bigint(19) not null auto_increment, primary key (id)) ENGINE MyISAM';
   prepare create_seq_stmt from @create_seq;
   execute create_seq_stmt;

  execute alter_seq_stmt; 
  deallocate prepare alter_seq_stmt;
  
  select max(numericVal(GRP_ID)) + 1 into l_new_seq from KRIM_GRP_T where numericVal(GRP_ID) < 10000;
  set @create_seq := 'CREATE TABLE KRIM_GRP_ID_BS_S (id bigint(19) not null auto_increment, primary key (id)) ENGINE MyISAM';
  prepare create_seq_stmt from @create_seq;
  execute create_seq_stmt;

  execute alter_seq_stmt;
  deallocate prepare alter_seq_stmt;
  
  select ifnull(max(numericVal(ROLE_ID)) + 1,1) into l_new_seq from KRIM_ROLE_T where numericVal(ROLE_ID) < 10000;
  set @create_seq := 'CREATE TABLE KRIM_ROLE_ID_BS_S (id bigint(19) not null auto_increment, primary key (id)) ENGINE MyISAM';
  prepare create_seq_stmt from @create_seq;
  execute create_seq_stmt;
