Commit 976fadc3 authored by Maxym Borodenko's avatar Maxym Borodenko

Fix: Invalid handling of collCode, collNumb

parent 5af68cd0
......@@ -5540,3 +5540,28 @@ databaseChangeLog:
name: bio19
indexName: UK_tllx8suofq27njhc60y6h1ii9
tableName: tile_climate
- changeSet:
id: 1550049944680-1
author: mborodenko
changes:
- sql:
comment: Convert current incorrect data for collCode to two records
sql: drop table if exists t_collCode;
create table if not exists t_collCode as
select
@num_e := 1 + LENGTH(collCode) - LENGTH(REPLACE(collCode, ';', '')) AS num_e,
collectId, collCode,
SUBSTRING_INDEX(collCode,';',1) as coll1,
IF(@num_e > 1, SUBSTRING_INDEX(SUBSTRING_INDEX(collCode,';',2),';',-1), null) coll2,
IF(@num_e > 2, SUBSTRING_INDEX(SUBSTRING_INDEX(collCode,';',3),';',-1), null) coll3,
IF(@num_e > 3, SUBSTRING_INDEX(SUBSTRING_INDEX(collCode,';',3),';',-1), null) coll4
from accession_collect_code where collCode is not null and (LENGTH(collCode) - LENGTH(REPLACE(collCode, ';', ''))) > 0;
delete from accession_collect_code where collectId in (select distinct collectId from t_collCode);
insert into accession_collect_code (collectId,collCode)
(select distinct collectId, coll1 from
(select collectId, coll1 from t_collCode where coll1 is not null
union all select collectId, coll2 from t_collCode where coll2 is not null
union all select collectId, coll3 from t_collCode where coll3 is not null
union all select collectId, coll4 from t_collCode where coll4 is not null) Q);
drop table t_collCode;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment