
create TEMPORARY TABLE CHANGE_GROUPS(START INTEGER, LENGTH INTEGER, CONTENT_ID_INTERNAL INTEGER, ID_TO_REPLACE INTEGER, NEW_ID INTEGER) ;

insert into CHANGE_GROUPS(START,LENGTH, CONTENT_ID_INTERNAL)
 select '40', POSITION(',' IN WRITERS)-40, ID_INTERNAL FROM CONTENT WHERE WRITERS LIKE '%unitSiteManagers%';

update CONTENT C, CHANGE_GROUPS CG set CG.ID_TO_REPLACE= SUBSTRING(C.WRITERS,CG.START,CG.LENGTH) WHERE C.ID_INTERNAL=CG.CONTENT_ID_INTERNAL;

update CONTENT C, CHANGE_GROUPS GC set GC.NEW_ID = C.ID_INTERNAL WHERE C.OJB_CONCRETE_CLASS Like '%Site' AND C.OLD_ID_INTERNAL = GC.ID_TO_REPLACE;

update CONTENT C, CHANGE_GROUPS CG set C.WRITERS = REPLACE(C.WRITERS, CG.ID_TO_REPLACE, CG.NEW_ID) WHERE C.ID_INTERNAL=CG.CONTENT_ID_INTERNAL;

drop TEMPORARY TABLE CHANGE_GROUPS;
