1
General Board / Re: Duplicate Tagged Values
« on: May 15, 2008, 05:10:10 pm »
If you use database repository you can repair duplicated tagged values with the following script. The script relies on the fact, that a duplicate tagged value always has higher propertyid than the original one. It simply moves the value to the newer one and deletes the older one, keeping only the profiled tagged value in place. Before running the script synchronize tagged values for all of your stereotypes to produce duplicates.
The script was written for Oracle database.
Viliam Durina
The script was written for Oracle database.
Code: [Select]
-- ATTRIBUTES #######
update T_ATTRIBUTETAG at
set value=(
select value
from T_ATTRIBUTETAG at2
where at2.elementid=at.elementid and at2.property=at.property
and at2.propertyid=(
select min(at3.propertyid)
from T_ATTRIBUTETAG at3
where at3.elementid=at2.elementid and at2.property=at3.property
)
)
where
at.propertyid=(
select max(propertyid)
from T_ATTRIBUTETAG at4
where at4.elementid=at.elementid and at4.property=at.property
having count(*)>1
);
delete
from t_attributetag ta
where ta.propertyid=(
select min(ta2.propertyid)
from t_attributetag ta2
where ta2.elementid=ta.elementid and ta2.property=ta.property
having count(*)>1
);
-- METHODS #######
update T_OPERATIONTAG at
set value=(
select value
from T_OPERATIONTAG at2
where at2.elementid=at.elementid and at2.property=at.property
and at2.propertyid=(
select min(at3.propertyid)
from T_OPERATIONTAG at3
where at3.elementid=at2.elementid and at2.property=at3.property
)
)
where
at.propertyid=(
select max(propertyid)
from T_OPERATIONTAG at4
where at4.elementid=at.elementid and at4.property=at.property
having count(*)>1
);
delete
from T_OPERATIONTAG ta
where ta.propertyid=(
select min(ta2.propertyid)
from T_OPERATIONTAG ta2
where ta2.elementid=ta.elementid and ta2.property=ta.property
having count(*)>1
);
-- CONNECTORS #######
update T_CONNECTORTAG at
set value=(
select value
from T_CONNECTORTAG at2
where at2.elementid=at.elementid and at2.property=at.property
and at2.propertyid=(
select min(at3.propertyid)
from T_CONNECTORTAG at3
where at3.elementid=at2.elementid and at2.property=at3.property
)
)
where
at.propertyid=(
select max(propertyid)
from T_CONNECTORTAG at4
where at4.elementid=at.elementid and at4.property=at.property
having count(*)>1
);
delete
from T_CONNECTORTAG ta
where ta.propertyid=(
select min(ta2.propertyid)
from T_CONNECTORTAG ta2
where ta2.elementid=ta.elementid and ta2.property=ta.property
having count(*)>1
);
-- CLASSES #######
update T_OBJECTPROPERTIES at
set value=(
select value
from T_OBJECTPROPERTIES at2
where at2.object_id=at.object_id and at2.property=at.property
and at2.propertyid=(
select min(at3.propertyid)
from T_OBJECTPROPERTIES at3
where at3.object_id=at2.object_id and at2.property=at3.property
)
)
where
at.propertyid=(
select max(propertyid)
from T_OBJECTPROPERTIES at4
where at4.object_id=at.object_id and at4.property=at.property
having count(*)>1
);
delete
from T_OBJECTPROPERTIES ta
where ta.propertyid=(
select min(ta2.propertyid)
from T_OBJECTPROPERTIES ta2
where ta2.object_id=ta.object_id and ta2.property=ta.property
having count(*)>1
);
commit;
Viliam Durina