do $$
begin
	if exists (
		select 1 from VCLib.T_CLIENT_MODULES
		where ModuleType = 'IESClientCommandUIHandler'
	)
	then
		delete from VCLib.T_ROLE_CLIENT_MODULES
		where ClientModuleID in (
			select ClientModuleID from VCLib.T_CLIENT_MODULES
			where ModuleType = 'IESClientCommandUIHandler'
		);
	
		delete from VCLib.T_CLIENT_MODULES
		where ModuleType = 'IESClientCommandUIHandler';
	end if;
end;
$$ language plpgsql;