select
icmc.community_id as com_id,
icmc.lorsm_instance_id as lors_ins_id,
icmc.isenabled as ie,
icmc.istrackable as it
from
ims_cp_manifest_class icmc
where
icmc.man_id in ( select revision_id
from cr_revisions
where item_id = :version_id )
update ims_cp_manifest_class
set
man_id = :man_id,
lorsm_instance_id = :lors_ins_id,
isenabled = :ie,
istrackable = :it
where
community_id = :com_id
delete from ims_cp_manifest_class
where
community_id is null and
man_id = :man_id