labtech
Database
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
CleanupCacheEventDates
Parameters
Name
Type
Mode
Definition
BEGIN -- This stored procedure is intended to keep the cacheeventdates tables with the least amount of records as possible while still keeping at least one entry per eventsource type. DROP TEMPORARY TABLE IF EXISTS `tempCacheEventDates`; CREATE TEMPORARY TABLE `tempCacheEventDates` (EventSource VARCHAR(50),eventdate TIMESTAMP); INSERT INTO `tempCacheEventDates` SELECT 'Agents', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Agents'; INSERT INTO `tempCacheEventDates` SELECT 'Apps', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Apps'; INSERT INTO `tempCacheEventDates` SELECT 'AuditActions', MAX(EventDate) FROM CacheEventDates WHERE EventSource='AuditActions'; INSERT INTO `tempCacheEventDates` SELECT 'CCommands', MAX(EventDate) FROM CacheEventDates WHERE EventSource='CCommands'; INSERT INTO `tempCacheEventDates` SELECT 'Clients', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Clients'; INSERT INTO `tempCacheEventDates` SELECT 'CMenus', MAX(EventDate) FROM CacheEventDates WHERE EventSource='CMenus'; INSERT INTO `tempCacheEventDates` SELECT 'Computers', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Computers'; INSERT INTO `tempCacheEventDates` SELECT 'Config', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Config'; INSERT INTO `tempCacheEventDates` SELECT 'ConfigOutlook', MAX(EventDate) FROM CacheEventDates WHERE EventSource='ConfigOutlook'; INSERT INTO `tempCacheEventDates` SELECT 'Contacts', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Contacts'; INSERT INTO `tempCacheEventDates` SELECT 'ControlCenterConfig', MAX(EventDate) FROM CacheEventDates WHERE EventSource='ControlCenterConfig'; INSERT INTO `tempCacheEventDates` SELECT 'DataViewFolders', MAX(EventDate) FROM CacheEventDates WHERE EventSource='DataViewFolders'; INSERT INTO `tempCacheEventDates` SELECT 'DataViews', MAX(EventDate) FROM CacheEventDates WHERE EventSource='DataViews'; INSERT INTO `tempCacheEventDates` SELECT 'Functions', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Functions'; INSERT INTO `tempCacheEventDates` SELECT 'Groups', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Groups'; INSERT INTO `tempCacheEventDates` SELECT 'Huds', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Huds'; INSERT INTO `tempCacheEventDates` SELECT 'Links', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Links'; INSERT INTO `tempCacheEventDates` SELECT 'Locations', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Locations'; INSERT INTO `tempCacheEventDates` SELECT 'Permissions', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Permissions'; INSERT INTO `tempCacheEventDates` SELECT 'Properties', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Properties'; INSERT INTO `tempCacheEventDates` SELECT 'Redirectors', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Redirectors'; INSERT INTO `tempCacheEventDates` SELECT 'Regions', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Regions'; INSERT INTO `tempCacheEventDates` SELECT 'RemoteCommands', MAX(EventDate) FROM CacheEventDates WHERE EventSource='RemoteCommands'; INSERT INTO `tempCacheEventDates` SELECT 'ReportFolders', MAX(EventDate) FROM CacheEventDates WHERE EventSource='ReportFolders'; INSERT INTO `tempCacheEventDates` SELECT 'Reports', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Reports'; INSERT INTO `tempCacheEventDates` SELECT 'RoleDefinitions', MAX(EventDate) FROM CacheEventDates WHERE EventSource='RoleDefinitions'; INSERT INTO `tempCacheEventDates` SELECT 'Schedules', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Schedules'; INSERT INTO `tempCacheEventDates` SELECT 'ScriptFolders', MAX(EventDate) FROM CacheEventDates WHERE EventSource='ScriptFolders'; INSERT INTO `tempCacheEventDates` SELECT 'Scripts', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Scripts'; INSERT INTO `tempCacheEventDates` SELECT 'SensorChecks', MAX(EventDate) FROM CacheEventDates WHERE EventSource='SensorChecks'; INSERT INTO `tempCacheEventDates` SELECT 'Templates', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Templates'; INSERT INTO `tempCacheEventDates` SELECT 'TicketCategory', MAX(EventDate) FROM CacheEventDates WHERE EventSource='TicketCategory'; INSERT INTO `tempCacheEventDates` SELECT 'TicketData', MAX(EventDate) FROM CacheEventDates WHERE EventSource='TicketData'; INSERT INTO `tempCacheEventDates` SELECT 'TimeCategory', MAX(EventDate) FROM CacheEventDates WHERE EventSource='TimeCategory'; INSERT INTO `tempCacheEventDates` SELECT 'UserFolders', MAX(EventDate) FROM CacheEventDates WHERE EventSource='UserFolders'; INSERT INTO `tempCacheEventDates` SELECT 'Users', MAX(EventDate) FROM CacheEventDates WHERE EventSource='Users'; INSERT INTO `tempCacheEventDates` SELECT 'VirusScanners', MAX(EventDate) FROM CacheEventDates WHERE EventSource='VirusScanners'; TRUNCATE `CacheEventDates`; INSERT IGNORE INTO `CacheEventDates` (`EventSource`,`EventDate`) SELECT `EventSource`,`EventDate` FROM `tempCacheEventDates`; DROP TEMPORARY TABLE IF EXISTS `tempCacheEventDates`; CALL PopulateCacheEventDates(); END