   execute alter_seq_stmt;
   deallocate prepare alter_seq_stmt;
   
-  select max(numericVal(ROLE_ID)) + 1 into l_new_seq from KRIM_ROLE_T where numericVal(ROLE_ID) < 10000;
+  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;

  execute alter_seq_stmt;
  deallocate prepare alter_seq_stmt;

  select max(numericVal(ROLE_RSP_ID)) + 1 into l_new_seq from KRIM_ROLE_RSP_T where numericVal(ROLE_RSP_ID) < 10000;
  set @create_seq := 'CREATE TABLE KRIM_ROLE_RSP_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(ID)) + 1,1) into l_new_seq from 
    ((select ifnull(max(numericVal(ATTR_DATA_ID)),0) as ID from KRIM_RSP_ATTR_DATA_T where numericVal(ATTR_DATA_ID) < 10000) 
      union (select ifnull(max(numericVal(ATTR_DATA_ID)),0) as ID from KRIM_DLGN_MBR_ATTR_DATA_T where numericVal(ATTR_DATA_ID) < 10000)
      union (select ifnull(max(numericVal(ATTR_DATA_ID)),0) as ID from KRIM_ROLE_MBR_ATTR_DATA_T where numericVal(ATTR_DATA_ID) < 10000)
      union (select ifnull(max(numericVal(ATTR_DATA_ID)),0) as ID from KRIM_PERM_ATTR_DATA_T where numericVal(ATTR_DATA_ID) < 10000)) as t1;
  set @create_seq := 'CREATE TABLE KRIM_ATTR_DATA_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;
