   execute alter_seq_stmt;
   deallocate prepare alter_seq_stmt;
   
-  select max(numericVal(ID)) + 1 into l_new_seq from 
-    ((select max(numericVal(ATTR_DATA_ID)) as ID from KRIM_RSP_ATTR_DATA_T where numericVal(ATTR_DATA_ID) < 10000) 
-      union (select max(numericVal(ATTR_DATA_ID)) as ID from KRIM_DLGN_MBR_ATTR_DATA_T where numericVal(ATTR_DATA_ID) < 10000)
-      union (select max(numericVal(ATTR_DATA_ID)) as ID from KRIM_ROLE_MBR_ATTR_DATA_T where numericVal(ATTR_DATA_ID) < 10000)
-      union (select max(numericVal(ATTR_DATA_ID)) as ID from KRIM_PERM_ATTR_DATA_T where numericVal(ATTR_DATA_ID) < 10000)) as t1;
+  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;

  execute alter_seq_stmt;
  deallocate prepare alter_seq_stmt;
  
  select max(numericVal(KIM_TYP_ATTR_ID)) + 1 into l_new_seq from KRIM_TYP_ATTR_T where numericVal(KIM_TYP_ATTR_ID) < 10000;
  set @create_seq := 'CREATE TABLE KRIM_TYP_ATTR_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(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;
