delete from VCLib.T_ReportFileParameter
using VCLib.T_ReportFile, VCLib.T_ReportFileGroup, VCLib.T_Report, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_ReportFileParameter.FileID=VCLib.T_ReportFile.FileID
    and VCLib.T_ReportFile.GroupID=VCLib.T_ReportFileGroup.GroupID
    and VCLib.T_ReportFileGroup.ReportID=VCLib.T_Report.ReportID
    and VCLib.T_Report.EntityID=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_GR_ATTACHMENT_ITEM
using VCLib.T_GENERIC_REPORT_MAIN_ITEM, VCLib.T_GENERIC_REPORT, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_GR_ATTACHMENT_ITEM.GenericReportMainItem=VCLib.T_GENERIC_REPORT_MAIN_ITEM.GenericReportMainItemID
    and VCLib.T_GENERIC_REPORT_MAIN_ITEM.GenericReport=VCLib.T_GENERIC_REPORT.GenericReportID
    and VCLib.T_GENERIC_REPORT.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_ReportFile
using VCLib.T_ReportFileGroup, VCLib.T_Report, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_ReportFile.GroupID=VCLib.T_ReportFileGroup.GroupID
    and VCLib.T_ReportFileGroup.ReportID=VCLib.T_Report.ReportID
    and VCLib.T_Report.EntityID=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DICTIONARY_ATTRIBUTE_KEY
using VCLib.T_DICTIONARY_ATTRIBUTE, VCLib.T_DICTIONARY_UPDATE, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DICTIONARY_ATTRIBUTE_KEY.DictionaryAttribute=VCLib.T_DICTIONARY_ATTRIBUTE.DictionaryAttributeID
    and VCLib.T_DICTIONARY_ATTRIBUTE.DictionaryUpdate=VCLib.T_DICTIONARY_UPDATE.DictionaryUpdateID
    and VCLib.T_DICTIONARY_UPDATE.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DTO_MODEL_COLUMN
using VCLib.T_DTO_MODEL_VIEW, VCLib.T_DTO_MODEL, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DTO_MODEL_COLUMN.DtoModelView=VCLib.T_DTO_MODEL_VIEW.DtoModelViewID
    and VCLib.T_DTO_MODEL_VIEW.DtoModel=VCLib.T_DTO_MODEL.DtoModelID
    and VCLib.T_DTO_MODEL.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_UNITED_OBJECT_CHANGESET
using VCLib.T_UNITED_OBJECT, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_UNITED_OBJECT_CHANGESET.UnitedObject=VCLib.T_UNITED_OBJECT.UnitedObjectID
    and VCLib.T_UNITED_OBJECT.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DTO_MODEL_FILTER
using VCLib.T_DTO_MODEL, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DTO_MODEL_FILTER.DtoModel=VCLib.T_DTO_MODEL.DtoModelID
    and VCLib.T_DTO_MODEL.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DTO_MODEL_VIEW
using VCLib.T_DTO_MODEL, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DTO_MODEL_VIEW.DtoModel=VCLib.T_DTO_MODEL.DtoModelID
    and VCLib.T_DTO_MODEL.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DTO_ITEM
using VCLib.T_DTO_MODEL, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DTO_ITEM.ItemDtoModel=VCLib.T_DTO_MODEL.DtoModelID
    and VCLib.T_DTO_MODEL.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_TEMPLATE_FIELD_VALUE
using VCLib.T_TEMPLATE_FIELD, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_TEMPLATE_FIELD_VALUE.TemplateField=VCLib.T_TEMPLATE_FIELD.TemplateFieldID
    and VCLib.T_TEMPLATE_FIELD.Entity=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_LEXEM_PARAMETER
using VCLib.T_TEMPLATE_OVERRIDE, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_LEXEM_PARAMETER.TemplateOverride=VCLib.T_TEMPLATE_OVERRIDE.TemplateOverrideID
    and VCLib.T_TEMPLATE_OVERRIDE.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DTO_ITEM
using VCLib.T_DTO_MODEL, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DTO_ITEM.ItemDtoModel=VCLib.T_DTO_MODEL.DtoModelID
    and VCLib.T_DTO_MODEL.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DICTIONARY_DEPEND
using VCLib.T_DICTIONARY_UPDATE, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DICTIONARY_DEPEND.DictionaryUpdate=VCLib.T_DICTIONARY_UPDATE.DictionaryUpdateID
    and VCLib.T_DICTIONARY_UPDATE.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DICTIONARY_DEPEND
using VCLib.T_DICTIONARY_UPDATE, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DICTIONARY_DEPEND.DictionaryUpdate=VCLib.T_DICTIONARY_UPDATE.DictionaryUpdateID
    and VCLib.T_DICTIONARY_UPDATE.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DICTIONARY_USER
using VCLib.T_DICTIONARY_UPDATE, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DICTIONARY_USER.DictionaryUpdate=VCLib.T_DICTIONARY_UPDATE.DictionaryUpdateID
    and VCLib.T_DICTIONARY_UPDATE.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DATAFORM_EXTENSION_ADDATTRIBUTE
using VCLib.T_DATAFORM_EXTENSION, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DATAFORM_EXTENSION_ADDATTRIBUTE.DataformExtension=VCLib.T_DATAFORM_EXTENSION.DataformExtensionID
    and VCLib.T_DATAFORM_EXTENSION.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DATAFORM_EXTENSION_ROLE
using VCLib.T_DATAFORM_EXTENSION, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DATAFORM_EXTENSION_ROLE.DataformExtension=VCLib.T_DATAFORM_EXTENSION.DataformExtensionID
    and VCLib.T_DATAFORM_EXTENSION.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DICTIONARY_ATTRIBUTE
using VCLib.T_DICTIONARY_UPDATE, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DICTIONARY_ATTRIBUTE.DictionaryUpdate=VCLib.T_DICTIONARY_UPDATE.DictionaryUpdateID
    and VCLib.T_DICTIONARY_UPDATE.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_VALIDATION_CONDITION
using VCLib.T_DATAFORM_VALIDATION, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_VALIDATION_CONDITION.DataformValidation=VCLib.T_DATAFORM_VALIDATION.Entities
    and VCLib.T_DATAFORM_VALIDATION.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_BASE_FEATURE_SETTINGS
using VCLib.T_CLIENT_MODULE_FEATURE, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_BASE_FEATURE_SETTINGS.ClientModuleFeature=VCLib.T_CLIENT_MODULE_FEATURE.ClientModuleFeatureID
    and VCLib.T_CLIENT_MODULE_FEATURE.EntityIndex=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DATA_ACCESS_ENTRY
using VCLib.T_DATA_ACCESS, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DATA_ACCESS_ENTRY.DataAccess=VCLib.T_DATA_ACCESS.DataAccessID
    and VCLib.T_DATA_ACCESS.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_REPORT_ATTACHMENT
using VCLib.T_Report, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_REPORT_ATTACHMENT.Report=VCLib.T_Report.ReportID
    and VCLib.T_Report.EntityID=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_ReportFileGroup
using VCLib.T_Report, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_ReportFileGroup.ReportID=VCLib.T_Report.ReportID
    and VCLib.T_Report.EntityID=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_ReportKey
using VCLib.T_Report, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_ReportKey.ReportID=VCLib.T_Report.ReportID
    and VCLib.T_Report.EntityID=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_SIMPLE_REPORT_MENU_ITEM
using VCLib.T_Report, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_SIMPLE_REPORT_MENU_ITEM.Report=VCLib.T_Report.ReportID
    and VCLib.T_Report.EntityID=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_EXPORT_COLUMN
using VCLib.T_EXPORT_TABLE, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_EXPORT_COLUMN.ExportTable=VCLib.T_EXPORT_TABLE.ExportTableID
    and VCLib.T_EXPORT_TABLE.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_EXPORT_ITEM
using VCLib.T_EXPORT_TABLE, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_EXPORT_ITEM.ExportTable=VCLib.T_EXPORT_TABLE.ExportTableID
    and VCLib.T_EXPORT_TABLE.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_GENERATOR_LINK
using VCLib.T_GENERIC_REPORT, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_GENERATOR_LINK.GenericReport=VCLib.T_GENERIC_REPORT.GenericReportID
    and VCLib.T_GENERIC_REPORT.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_GENERATOR_PARAMS
using VCLib.T_GENERIC_REPORT, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_GENERATOR_PARAMS.GenericReport=VCLib.T_GENERIC_REPORT.GenericReportID
    and VCLib.T_GENERIC_REPORT.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_GENERIC_REPORT_FUNCTION
using VCLib.T_GENERIC_REPORT, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_GENERIC_REPORT_FUNCTION.GenericReport=VCLib.T_GENERIC_REPORT.GenericReportID
    and VCLib.T_GENERIC_REPORT.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_GENERIC_REPORT_MAIN_ITEM
using VCLib.T_GENERIC_REPORT, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_GENERIC_REPORT_MAIN_ITEM.GenericReport=VCLib.T_GENERIC_REPORT.GenericReportID
    and VCLib.T_GENERIC_REPORT.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_ENTITIES_WEB_ALIAS_ACCESS
using VCLib.T_ENTITIES_WEB_ALIAS, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_ENTITIES_WEB_ALIAS_ACCESS.EntitiesWebAlias=VCLib.T_ENTITIES_WEB_ALIAS.Alias
    and VCLib.T_ENTITIES_WEB_ALIAS.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_IMPORTLOGITEM
using VCLib.T_IMPORTLOG, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_IMPORTLOGITEM.ImportLogID=VCLib.T_IMPORTLOG.ImportLogID
    and VCLib.T_IMPORTLOG.EntityID=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_ROLE_ATTRIBUTE_ACCESS
using VCLib.T_HIDDEN_ATTRIBUTE, VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_ROLE_ATTRIBUTE_ACCESS.HiddenAttribute=VCLib.T_HIDDEN_ATTRIBUTE.HiddenAttributeID
    and VCLib.T_HIDDEN_ATTRIBUTE.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_HIDDEN_ATTRIBUTE
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_HIDDEN_ATTRIBUTE.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_IMPORTLOG
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_IMPORTLOG.EntityID=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_CLIENT_MODULE_FORM
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_CLIENT_MODULE_FORM.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_ENTITIES_WEB_ALIAS
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_ENTITIES_WEB_ALIAS.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_EXTRA_UI_COMMAND
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_EXTRA_UI_COMMAND.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_OBJECT_COPY_TEMPLATE
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_OBJECT_COPY_TEMPLATE.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_EXTRA_UI_COMMAND
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_EXTRA_UI_COMMAND.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_GENERIC_REPORT
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_GENERIC_REPORT.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_CASCADE_DELETE_SETTING
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_CASCADE_DELETE_SETTING.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_NOTIFY_MESSAGE_TYPE
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_NOTIFY_MESSAGE_TYPE.NotifyEntity=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_NOTIFY_MESSAGE_TYPE
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_NOTIFY_MESSAGE_TYPE.NotifyEntity=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_NOTIFY_MESSAGE_OBJECT
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_NOTIFY_MESSAGE_OBJECT.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_PROCESS_ACCESS_ENTRY
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_PROCESS_ACCESS_ENTRY.EntityID=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_Report
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_Report.EntityID=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DATAFORM_EXTENSION
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DATAFORM_EXTENSION.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DATA_ACCESS
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DATA_ACCESS.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_CLIENT_MODULE_FEATURE
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_CLIENT_MODULE_FEATURE.EntityIndex=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DICTIONARY_UPDATE
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DICTIONARY_UPDATE.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DATAFORM_TEMPLATE
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DATAFORM_TEMPLATE.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DATAFORM_VALIDATION
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DATAFORM_VALIDATION.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_DTO_MODEL
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_DTO_MODEL.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_ENTITY_ACCESS_ENTRY
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_ENTITY_ACCESS_ENTRY.EntityID=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_TEMPLATE_OVERRIDE
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_TEMPLATE_OVERRIDE.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_ENT_ATTR_ACCESS_ENTRY
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_ENT_ATTR_ACCESS_ENTRY.EntityID=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_ENTITIES_ATTRIBUTES
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_ENTITIES_ATTRIBUTES.EntityID=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_TEMPLATE_FIELD
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_TEMPLATE_FIELD.Entity=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_UNITED_OBJECT_CHANGESET
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_UNITED_OBJECT_CHANGESET.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_USER_SEARCHES
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_USER_SEARCHES.EntityID=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_EXPORT_TABLE
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_EXPORT_TABLE.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_UNITED_OBJECT
using VCLib.T_ENTITIES 
where Schema = 'FIES' and EntName like 'CHAT%'
    and VCLib.T_UNITED_OBJECT.Entities=VCLib.T_ENTITIES.EntityID;

delete from VCLib.T_ENTITIES
where Schema = 'FIES' and EntName like 'CHAT%';
